< Localization

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:

Basic Chinese support

To properly display Chinese, you must set the locale correctly and install the appropriate Chinese fonts.

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):

zh_CN.GB2312
zh_CN.GBK
zh_CN.GB18030
zh_CN.UTF-8
zh_TW.BIG-5
zh_TW.UTF-8

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):

en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8

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 to view the currently available locales.

Set the global default locale to English (optional)

To avoid the tty garbled text issue mentioned above, globally set the LANG locale to in :

LANG=en_US.UTF-8
User-specific locales

You may set your own user environment variables in , ~/.xinitrc, or ~/.xprofile.

  • .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 because it causes tty to display garbled characters.

As mentioned earlier, Chinese locale can be set separately in ~/.xinitrc or ~/.xprofile. Prepend the following two lines to one of the two files (if you are not sure which file to use, prepend to both):

export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN:en_US

Install fonts

In addition to locales, Chinese fonts are also required.

Commonly used free (GPL or compatible copyright) Chinese fonts include:

System fonts will be installed to by default. If you do not have root authority or plan to use certain fonts yourself, you can directly copy these fonts to (or its subdirectories) and add the path to . For details, go over the following chapters.

See also:

fontconfig settings

The setting file of fontconfig is (user) or (global). It is recommended to modify the former.

For Chinese fonts settings, see Fonts (简体中文) and Font configuration (简体中文).

Font Configuration (简体中文)/Chinese (简体中文) provides a demonstration of Chinese fontconfig.

See also:

Fixed Simplified Chinese display as a variant (Japanese) glyph

After installing Noto Sans CJK, (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 is before , Japanese fonts are used first.

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-serif-cn-fonts or noto-fonts-scAUR.
  • Add to 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. :

Create a file under or , such as , or modify or create (only effective for the user):

If noto-fonts-cjk is installed, write:

If you have installed :

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <alias>
    <family>sans-serif</family>
    <prefer>
      <family>Source Han Sans SC</family>
      <family>Source Han Sans TC</family>
      <family>Source Han Sans HW</family>
      <family>Source Han Sans K</family>
    </prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer>
      <family>Source Han Sans SC</family>
      <family>Source Han Sans TC</family>
      <family>Source Han Sans HW</family>
      <family>Source Han Sans K</family>
    </prefer>
  </alias>
</fontconfig>

Note that if you create an xml file under , for example:

# ln -s /etc/fonts/conf.avail/64-language-selector-prefer.conf /etc/fonts/conf.d/64-language-selector-prefer.conf

you have to update the font cache to take effect:

# fc-cache -fv

Execute the following command to check. If appears, the settings are successfully applied:

# fc-match -s | grep 'Noto Sans CJK'

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.

Terminal Chinese support

Bootloader Chinese support

See GRUB2 (简体中文).

Cultural configuration in software

Firefox

Simplified Chinese installation: firefox-i18n-zh-cn

Traditional Chinese installation: 。

Libreoffice

Simplified Chinese installation: or .

Traditional Chinese installation: or .

PDF reader

Most PDF viewers already support Chinese. However, there are some additional language packs/fonts that need to be installed:

Arcobat's fonts are , or acroread-fonts-systemwideAUR for system-wide fonts.

For -based readers (e.g., , Evince) and image processing tools that can handle PDF files (e.g., Inkscape, , ), needs to be installed.

Java

For Sun Java users, create a directory under /opt/java/jre/lib/fonts, then link or copy several Chinese fonts to the directory to allow java programs to display Chinese correctly. For example, if and have been installed, use the following command:

# ln -s /usr/share/fonts/TTF/odosung.ttc /opt/java/jre/lib/fonts/fallback/
# cd /opt/java/jre/lib/fonts/fallback/
# mkfontdir
# mkfontscale

vim

If the locale is utf8-encoded, using vim to open other Chinese encoded files may be garbled. The following settings need to be made in ~/.vimrc:

MPlayer

To allow MPlayer to display Chinese subtitles correctly, the key is to make sure the encoding of the subtitle file is consistent with the encoding used in mplayer's configurations. If the subtitle file is encoded as gbk, use ; If the subtitle file is encoded as utf-8, use . If the subtitle file is encoded as utf-8 and set to , some garbled characters will appear. Another simpler method is to set to , so that enca is responsible for the encoding and display of subtitles.

Modify :

Use the following command to manually load subtitles:

$ mplayer xxx.avi -sub xxxxx.srt

If a graphical front end (such as SMPlayer) is used, it will work as long as you set the default subtitle encoding and font in the settings dialog box.

xine

Xine can also display Chinese subtitles, but you need to make your own Chinese fonts. For details, please refer to .

gstreamer

In totem 1.4.0, since gstreamer0.10 is used, it should be able to automatically load srt subtitles with the same name.

LaTeX

You need to install CJK packages and the appropriate fonts. For details, please refer to .

Garbled problem

The basic principle to avoid garbled characters is to use utf-8 instead of gbk/gb2312.

File name is garbled

Install and use the command to convert the encoding format. For example:

$ convmv -f GBK -t UTF-8 --notest --nosmart file

-f specifies the original encoding, and specifies the output encoding. Use to find out all the supported encodings. --notest means not to test but to transcode (if you do not use this parameter, the conversion result will be printed instead of actual transcoding), allows to ignore the request if it is already in UTF-8.

File content is garbled

Use the command to convert the format. For example:

$ iconv -f GBK -t UTF-8 -o new-file origin-file

-f specifies the original encoding, and specifies the output encoding. Use to query all supported encodings. specifies the output file.

zip compressed package is garbled

Under non-utf8 coding environments (generally the Chinese environment under Windows), do not use zip for compressions (7z is recommended). A special parameter is needed:

$ unzip -O gbk file.zip
is the encoding format of the file, specified with .

Alternatively, use unzip-natspecAUR.

MP3 file label garbled

For players that use GStreamer as the backend, such as Rhythmbox and totem, after setting the following environment variables, the GB3 encoded ID3 tag in mp3 can be read correctly:

export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030

For Beep media player, you can select MPEG Audio plugin in , and then click Penfenrences below. A dialog box will appear. Select title, tick . Fill in in ID3 encoding. Now, BMP can correctly display the GB3 encoded ID3 tag.

Quod Libet player supports tag editing and setting ID3v2 encoding. This can be set in :

The best solution is to convert the id3 tag encoded as gbk to utf8 encoding. Install python-mutagen, then use the following command to convert:

$ mid3iconv -e gbk XXX.mp3

Garbled Chinese file name under Windows partition

Generally, the mounted character set is different from the locales. You can modify (if you do not understand, please read fstab carefully). If the locale is utf8, modify the line to:

If the locale is GBK, it should be:

Samba garbled

When using Arch as a Samba server, adding the following line to can solve the garbled problem of Windows clients:

/etc/samba/smb.conf
...
unix charset=gb2312
...

ftp garbled

Many ftp sites are GBK encoded. If you use UTF8 locale, the downloaded file name may be garbled. For lftp, make the following settings under :

For gftp, you can do the following settings in :

However, the downloaded file name is still garbled and needs to be patched and compiled. The patch address is: https://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch

Translation software

  • : StarDict.
  • : command line StarDict.
  • ydcv: Youdao dictionary on the command line.
  • : Youdao dictionary (graphic interface), screen word translation.
  • : There is no dictionary by default, you can download the corresponding dictionary package (supports Babylon's thesaurus format .BGL, StarDict no longer maintained thesaurus format (///), dictd words Library format (/(), ABBYY Lingvo's thesaurus format (.dsl//), mdict's thesaurus format, etc. The thesaurus files of these dictionaries can be downloaded and imported on the Internet Use of GoldenDict (may have copyright issues).
  • : A multi-platform Chinese dictionary. In addition to Chinese characters, words, idioms, etc., it also contains Hakka, Hokkien, simple foreign language translations, stroke order writing, etc. moedict online address
  • : An online English-Chinese dictionary that gets results by crawling Youdao translation webpage, some support English-Chinese translation, imitating dmenu to display the results at the top of the screen. It is rather easy to use. The API used by ydcv has expired, and the new API is free to use the frequency limit, so is a good alternative.
gollark: In the UK, there are better consumer protections on credit cards for what I am sure are horrific historical reasons.
gollark: Brevity good, actually.
gollark: "Correlated" doesn't mean "one causes all change in the other even in extreme circumstances".
gollark: Of course. Accurate proverbs are a vital national asset.
gollark: There are diminishing returns, but I don't think it's been found to actually go *down* with more money.
This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.