Answers:
检查支持哪些语言环境:
locale -a
添加所需的语言环境(例如ru
):
sudo locale-gen ru_RU
sudo locale-gen ru_RU.UTF-8
运行此更新命令:
sudo update-locale
ru_RU
和ru_RU.UTF-8
需要?我对语言环境不太了解。
sudo service php5-fpm restart
我会选择另一条路线,那就是IMO更适合Ubuntu风格。使用提供的软件包。每个语言环境都有相应的软件包,它们可以为您完成所有工作……无需编辑/ var文件,我一直认为这些文件不是要手动编辑的。
sudo apt-get install language-pack-XX
其中XX代表语言代码。安装语言还将安装所有国家/地区特定的变体(例如,安装language-pack-it将安装it_CH.utf8和it_IT.utf8,为NL安装将安装nl_AW,nl_AW.utf8,nl_BE.utf8和nl_NL.utf8 )。
echo ru_RU.UTF8 >> /var/lib/locales/supported.d/local
我在点3收到以下消息:“错误:错误的条目'ru_RU.UTF8'”
这项工作对我来说:
echo ru_RU.UTF-8 UTF-8 >> /var/lib/locales/supported.d/local
/var/lib/locales/supported.d/mintlocale
文件以包含这些行en_GB UTF-8
和en_GB.UTF-8 UTF-8
(缺少了多余的UTF-8)。
使用Ubuntu语言包。默认存储库中提供所有受支持的语言:
apt-cache search language-pack
Ubuntu(服务器)版本中语言环境切换的完整示例:
jani@example:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.1 LTS"
所有可用(即已安装)的语言环境都可以列出:
locale -a
我当前的语言环境是en_IE
:
jani@example:~$ locale
LANG=en_IE.UTF-8
LANGUAGE=
LC_CTYPE="en_IE.UTF-8"
LC_NUMERIC="en_IE.UTF-8"
LC_TIME="en_IE.UTF-8"
LC_COLLATE="en_IE.UTF-8"
LC_MONETARY="en_IE.UTF-8"
LC_MESSAGES=POSIX
LC_PAPER="en_IE.UTF-8"
LC_NAME="en_IE.UTF-8"
LC_ADDRESS="en_IE.UTF-8"
LC_TELEPHONE="en_IE.UTF-8"
LC_MEASUREMENT="en_IE.UTF-8"
LC_IDENTIFICATION="en_IE.UTF-8"
LC_ALL=
jani@example:~$ date
Sat Nov 1 15:36:51 UTC 2014
jani@example:~$
因为我没有ru语言环境,所以必须安装ru语言包:
jani@example:~$ sudo apt-get -y install language-pack-ru
[..]
Generating locales...
ru_RU.UTF-8... done
ru_UA.UTF-8... done
Generation complete.
jani@example:~$
现在可以使用ru语言环境。系统默认语言环境是通过编辑设置的/etc/default/locale
:
jani@example:~$ sudo vi /etc/default/locale
# Created by cloud-init v. 0.7.5 on Mon, 27 Oct 2014 18:46:13 +0000
LANG="ru_RU.UTF-8"
LC_MESSAGES=POSIX
jani@example:~$
重新登录并检查您的全新语言环境:
jani@example:~$ locale
LANG=ru_RU.UTF-8
LANGUAGE=
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES=POSIX
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=
jani@example:~$ date
Сб. нояб. 1 15:43:45 UTC 2014
jani@example:~$
我以类似的方式进行了操作,以在不重新启动或注销的情况下将语言环境应用到整个系统。
首先,下载语言包:
sudo apt-get install language-pack-ru-base
接下来,检查支持哪些版本:
less /usr/share/i18n/SUPPORTED | grep ru_RU
现在,应用结果(几乎总是将UTF-8版本用于几乎所有语言!):
echo 'ru_RU.UTF-8 UTF-8' | sudo tee /var/lib/locales/supported.d/local
sudo dpkg-reconfigure locales
最后,更新默认文件,获取源文件,然后完成:
echo 'LANG=ru_RU.UTF-8' | sudo tee /etc/default/locale
将更改应用到系统:
. /etc/default/locale
LANGUAGE=ru_RU.UTF-8
并检查结果:
locale
sudo update-locale