- Locale
- Contents
- Generating locales
- Setting the locale
- Setting the system locale
- Overriding system locale per user session
- Make locale changes immediate
- Other uses
- Variables
- LANG: default locale
- LANGUAGE: fallback locales
- LC_TIME: date and time format
- LC_COLLATE: collation
- LC_ALL: troubleshooting
- Troubleshooting
- My terminal does not support UTF-8
- Gnome-terminal or rxvt-unicode
- My system is still using wrong language
- Localization/Simplified Chinese
- Contents
- Basic Chinese support
- locale settings
- Install Chinese locale
- Enable Chinese locales
- Chinese fonts
- Install fonts
- Chinese fonts configuration
- Chinese input method
- Localization (Русский)
- Contents
- Настройка
- Локаль
- Виртуальная консоль
- Шрифты
- Клавиатура
- Советы и рекомендации
- Русские man-страницы
- Перекодировка тегов MP3
Locale
Locales are used by glibc and other locale-aware programs or libraries for rendering text, correctly displaying regional monetary values, time and date formats, alphabetic idiosyncrasies, and other locale-specific standards.
Contents
Generating locales
Locale names are typically of the form language[_territory][.codeset][@modifier] , where language is an ISO 639 language code, territory is an ISO 3166 country code, and codeset is a character set or encoding identifier like ISO-8859-1 or UTF-8. See setlocale(3) .
For a list of enabled locales, run:
Before a locale can be enabled on the system, it must be generated. This can be achieved by uncommenting applicable entries in /etc/locale.gen , and running locale-gen. Equivalently, commenting entries disables their respective locales. While making changes, consider any localisations required by other users on the system, as well as specific #Variables.
For example, uncomment en_US.UTF-8 UTF-8 for American-English:
Save the file, and generate the locale:
Setting the locale
To display the currently set locale and its related environmental settings, type:
The locale to be used, chosen among the previously generated ones, is set in locale.conf files. Each of these files must contain a new-line separated list of environment variable assignments, having the same format as output by locale.
To list available locales which have been previously generated, run:
Setting the system locale
To set the system locale, write the LANG variable to /etc/locale.conf , where en_US.UTF-8 belongs to the first column of an uncommented entry in /etc/locale.gen :
Overriding system locale per user session
The system-wide locale can be overridden in each user session by creating or editing $XDG_CONFIG_HOME/locale.conf (usually
The precedence of these locale.conf files is defined in /etc/profile.d/locale.sh .
/.config/locale.conf automatically generated.
Make locale changes immediate
Once system and user locale.conf files have been created or edited, their new values will take effect for new sessions at login. To have the current environment use the new settings unset LANG and source /etc/profile.d/locale.sh :
Other uses
Locale variables can also be defined with the standard methods as explained in Environment variables.
For example, in order to test or debug a particular application during development, it could be launched with something like:
Similarly, to set the locale for all processes run from the current shell (for example, during system installation):
Variables
locale.conf files support the following environment variables.
Full meaning of the above LC_* variables can be found on manpage locale(7) , whereas details of their definition are described on locale(5) .
LANG: default locale
The locale set for this variable will be used for all the LC_* variables that are not explicitly set.
LANGUAGE: fallback locales
Programs which use gettext for translations respect the LANGUAGE option in addition to the usual variables. This allows users to specify a list of locales that will be used in that order. If a translation for the preferred locale is unavailable, another from a similar locale will be used instead of the default. For example, an Australian user might want to fall back to British rather than US spelling:
LC_TIME: date and time format
If LC_TIME is set to en_US.UTF-8 , for example, the date format will be «MM/DD/YYYY». If wanting to use the the ISO 8601 date format of «YYYY-MM-DD» use:
glibc 2.29 fixed a bug, en_US.UTF-8 started showing in 12-hour format, as was intended. If wanting to use 24-hour format, use LC_TIME=en_GB.UTF-8 .
LC_COLLATE: collation
This variable governs the collation rules used for sorting and regular expressions.
Setting the value to C can for example make the ls command sort dotfiles first, followed by uppercase and lowercase filenames:
To get around potential issues, Arch used to set LC_COLLATE=C in /etc/profile , but this method is now deprecated.
LC_ALL: troubleshooting
The locale set for this variable will always override LANG and all the other LC_* variables, whether they are set or not.
LC_ALL is the only LC_* variable which cannot be set in locale.conf files: it is meant to be used only for testing or troubleshooting purposes, for example in /etc/profile .
Troubleshooting
My terminal does not support UTF-8
The following lists some (not all) terminals that support UTF-8:
Gnome-terminal or rxvt-unicode
You need to launch these applications from a UTF-8 locale or they will drop UTF-8 support. Enable the en_US.UTF-8 locale (or your local UTF-8 alternative) per the instructions above and set it as the default locale, then reboot.
My system is still using wrong language
It is possible that the environment variables are redefined in other files than locale.conf , for example
If you are using a desktop environment, such as GNOME, its language settings may be overriding the settings in locale.conf .
KDE Plasma also allows to change the UI’s language through the system settings. If the desktop environment is still using the default language after the modification, deleting the file at
/.config/plasma-locale-settings.sh ) should resolve the issue.
If you are using a display manager in combination with accountsservice , follow the instructions in Display manager#Set language for user session.
LightDM will automatically use accountsservice to set a user’s locale if it is installed. Otherwise, LightDM stores the user session configuration in
/.dmrc . It is possible that an unwanted locale setting is retrieved from there as well.
Источник
Localization/Simplified Chinese
According to «The Arch Way»: We cannot configure everything for you, because «Preferences and needs are different for everyone», but we will try to ensure the configuration to be convenient and simple. In fact, it is even easier than some Chinese versions of Linux.
This article provides Chinese cultural guidance for various common software as much as possible. But in practical applications, you may encounter all kinds of issues. Do not be discouraged when you are in trouble. Solving problems is a pleasure in itself. You can seek help through various platforms:
Contents
Basic Chinese support
To properly display Chinese, you must set the locale correctly and install the appropriate Chinese fonts.
locale settings
Install Chinese locale
In Linux, locales are used to set up different environments for running programs. Commonly used Chinese locales are (the most intuitive is the number of words that can be displayed):
It is recommended to use UTF-8 locale. You need to modify /etc/locale.gen to set the locales that can be used in the system (erase the comment symbol » # » before the corresponding item):
After executing locale-gen , the selected locales can be used in the system. You may use locale to view the currently used locale(s), and locale -a to view the currently available locales.
Enable Chinese locales
Set the global default locale to English (optional)
To avoid the tty garbled text issue mentioned above, globally set the LANG locale to en_US.UTF-8 in /etc/locale.conf :
User-specific locales
You may set your own user environment variables in
- .bashrc : Settings are applied everytime you log in using the terminal.
- .xinitrc : Settings are applied everytime you use startx or SLiM to start the X interface.
- .xprofile : Settings are applied everytime you log in using a display manager such as GDM.
Set Chinese locales for graphical interfaces
It is not recommended to set a global Chinese locale in /etc/locale.conf because it causes tty to display garbled characters.
As mentioned earlier, Chinese locale can be set separately in
/.xprofile . Prepend the following two lines to one of the two files (if you are not sure which file to use, prepend to both):
Chinese fonts
Install fonts
In addition to locales, Chinese fonts are also required.
Commonly used free (GPL or compatible copyright) Chinese fonts include:
This article or section is out of date.
/.fonts path is deprecated. It may be preferable to link to Fonts#Manual installation instead of duplicating information regarding font paths here. (Discuss in Talk:Localization/Simplified Chinese)
System fonts will be installed to /usr/share/fonts by default. If you do not have root authority or plan to use certain fonts yourself, you can directly copy these fonts to
/.fonts (or its subdirectories) and add the path to /etc/fonts/local.conf . For details, go over the following chapters.
Chinese fonts configuration
fontconfig settings
This article or section is out of date.
/.fonts.conf path appears to be deprecated. It may be preferable to link to Font configuration#Fontconfig configuration or Font configuration (简体中文)#Fontconfig配置 instead of explicitly mentioning font configuration paths. (Discuss in Talk:Localization/Simplified Chinese)
The setting file of fontconfig is
/.fonts.conf (user) or /etc/fonts/conf.d (global). It is recommended to modify the former.
Font Configuration (简体中文)/Chinese (简体中文) provides a demonstration of Chinese fontconfig.
Fixed Simplified Chinese display as a variant (Japanese) glyph
After installing Noto Sans CJK, adobe-source-han-sans-otc-fonts (Siyuan Bold) or adobe-source-han-serif-otc-fonts (Siyuan Song), in some cases (framework undefined area), rendered Chinese characters do not match the standard form, such as 门, 关, and 复.
This is because different default fonts can be set in each program, such as Arial or Tohamo, and the attributes of these fonts are controlled by fontconfig. The order of use is based on the regional code and the default order of A-Z. Since ja-JP is before zh_
You can use the following methods to solve the issue (taking simplified Chinese as an example):
- Only install Simplified Chinese fonts in cjk, such as Siyuan Bold Simplified Chinese package adobe-source-han-sans-cn-fonts , adobe-source-han-serif-cn-fonts or noto-fonts-scAUR .
- Add LANG=zh_CN.UTF-8 to locale.conf to set Simplified Chinese as the default language. Since the Locale is defined for CJK priority, the default priority is ignored.
- Manually adjust the priority so that the Chinese fonts are set before the Japanese fonts. [2]:
Create a file under /etc/fonts/conf.d/ or /etc/fonts/conf.avail/ , such as 64-language-selector-prefer.conf , or modify or create
/.fonts.conf (only effective for the user):
If noto-fonts-cjk is installed, write:
Note that if you create an xml file under /etc/fonts/conf.avail , for example:
you have to update the font cache to take effect:
Execute the following command to check. If NotoSansCJK-Regular.ttc: «Noto Sans CJK SC» «Regular» appears, the settings are successfully applied:
Chinese input method
Commonly used Chinese input method frameworks are IBus, fcitx and scim. For specific installation and configuration, please refer to the respective articles.
Источник
Localization (Русский)
Под локализацией (localization, l10n) и интернационализацией (internationalization, i18n) понимается процесс адаптации программного обеспечения к культуре какой-либо страны (см. Википедия:Локализация программного обеспечения).
В статье описано, как настроить поддержку русского языка в Arch Linux.
Contents
Настройка
Локализация системы подразумевает главным образом три вещи: настройку локали и настройку клавиатуры в виртуальной консоли и графическом окружении (Xorg). Ниже приведены краткие рекомендации по каждому из пунктов без углубления в детали. Более подробную информацию можно найти в профильных статьях:
Локаль
Локаль — набор параметров, определяющий региональные настройки пользовательского интерфейса, такие как язык, страна, часовой пояс, набор символов, формат вывода даты, времени, используемая денежная единица. Чтобы настроить русскую локаль в вашей системе, следуйте инструкциям ниже.
Отредактируйте файл /etc/locale.gen , раскомментировав строку ru_RU.UTF-8 UTF-8 , после чего сгенерируйте локаль:
Проверьте, что заявленная локаль теперь доступна, выполнив locale -a . Когда локаль сгенерирована, установите её в качестве системной:
Перезагрузитесь, чтобы изменения вступили в силу. Команда locale без аргументов выводит список относящихся к настройкам локали переменных окружения. Если всё в порядке, то приложения должны «русифицироваться».
Виртуальная консоль
Настройки виртуальной консоли хранятся в файле /etc/vconsole.conf . Создайте файл и добавьте в него следующие строки:
В примере используется шрифт cyr-sun16 из пакета kbd (установлен по умолчанию, зависимость systemd). Если необходим шрифт покрупнее, то набор Terminus содержит шрифты разных размеров с поддержкой кириллических символов. Установите пакет terminus-font , после чего задайте необходимый шрифт переменной FONT в файле /etc/vconsole.conf . Шрифты Terminus именуются по схеме ter-* , список доступных шрифтов можно вывести командой:
Изменения вступят в силу после перезагрузки. Переключение языков привязано к комбинации клавиш Ctrl+Shift .
Шрифты
Установите пакеты ttf-dejavu и ttf-liberation со шрифтами DejaVu и Liberation соответственно.
Клавиатура
Прежде всего необходимо узнать модель клавиатуры. Откройте графический эмулятор терминала (не виртуальную консоль!) и выполните:
Команда вернёт список основных настроек клавиатуры. Нас интересует значение в строке model: . Например, стандартная клавиатура для ПК будет называться pc104 или pc105 . Для игровых клавиатур и клавиатур ноутбуков, которые часто имеют дополнительные клавиши, значение будет другим.
Задайте настройки клавиатуры с помощью утилиты localectl:
- us,ru — устанавливаются две языковые раскладки (layouts), английская (основная) и русская (дополнительная).
- pc105 — модель клавиатуры; если ваша модель отличается, то укажите её.
- «» — т.н. вариант раскладки. Поскольку указана пустая строка, то для обеих языковых раскладок будет использоваться вариант qwerty .
- grp:alt_shift_toggle — блок дополнительных опций; в примере задаётся всего одна опция, переключение языков по комбинации клавиш Alt+Shift .
Перезапустите Xorg или перезагрузитесь, чтобы изменения вступили в силу.
Советы и рекомендации
Русские man-страницы
man показывает страницы с учётом локали. Для принудительного показа русских страниц используйте следующую команду:
Перекодировка тегов MP3
Установите пакет python-mutagen и выполните следующую команду в каталоге с коллекцией MP3-файлов:
Команда перекодирует старые теги из кодировки CP1251 в UTF8, запишет тег версии id3v2.4 и удалит теги первой версии.
Источник