我使用的是 Ubuntu 12.04,在自动更新后,它将系统默认编码从 UTF-8 更改为“ANSI_X3.4-1968”。我意识到当我在 Eclipse 中的代码注释出现奇怪的字符时,在意识到 IDE 没有问题后,我打开了一个终端进行检查。当我在终端窗口中输入拉丁字符(例如çãõéèê
...)时,会显示一个问号。当我cat
输入文本文件时也是如此。通过 GUI 更改 Ubuntu 区域设置会导致帐户守护程序崩溃:
ExecutablePath: /usr/bin/gnome-language-selector
ProcCmdline: /usr/bin/python /usr/bin/gnome-language-selector
...
File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking message, timeout)
DBusException: org.freedesktop.Accounts.Error.Failed: running '/usr/share/language-tools/save-to-pam-env' failed: no output
然后我改变了save-to-pam-env
添加调试行并lang-selector
在终端中执行了:
gag@desktop~> /usr/bin/python /usr/bin/gnome-language-selector
(gnome-language-selector:17733): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "pt_BR"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
...same message a dozen times...
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
/usr/lib/python2.7/dist-packages/LanguageSelector/gtk/GtkLanguageSelector.py:858: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
self._localeinfo.translate(loc, native=True) == defaultLangName):
//the line below is my debug 'print'
exec: /usr/share/language-tools/save-to-pam-env /home/likewise-open/CERTI/gag pt_BR.UTF-8
因此,手动运行此命令:
gag@desktop~> /usr/share/language-tools/save-to-pam-env /home/likewise-open/CERTI/gag pt_BR.UTF-8
pt_BR.UTF-8
gag@ccd-7840~> locale
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
gag@desktop~> cat .pam_environment
LANGUAGE=en
LANG=en_US.UTF-8
LC_NUMERIC=pt_BR.UTF-8
LC_TIME=pt_BR.UTF-8
LC_MONETARY=pt_BR.UTF-8
LC_PAPER=pt_BR.UTF-8
LC_NAME=pt_BR.UTF-8
LC_ADDRESS=pt_BR.UTF-8
LC_TELEPHONE=pt_BR.UTF-8
LC_MEASUREMENT=pt_BR.UTF-8
LC_IDENTIFICATION=pt_BR.UTF-8
一切似乎都很好,但重新启动 PC 并重新登录后,情况仍然相同。通过 CLI,我可以看到语言环境已正确安装:
gag@desktop~> locale -a | grep pt
pt_BR.utf8
pt_PT.utf8
gag@desktop~> locale -m | grep UTF
UTF-8
我也尝试过:
sudo apt-get install language-pack-pt language-pack-pt-base
sudo apt-get install --reinstall locales
没有效果。当我用另一个帐户登录时,编码没问题。有想法吗?
答案1
我在升级系统(xubuntu 12.04,使用 Likewise open)后遇到了同样的问题:如果我使用系统帐户登录,则没有任何问题,但如果我使用 AD 帐户登录,则无法使区域设置起作用(我的默认设置是 it_IT,但不知何故它被更改为 en_US)。
我尝试了您报告的相同命令,但没有成功,但最终更改了我的显示管理器成功了。
我认为这是 lightdm 的问题,因此我尝试切换到其他 DM(slim):
sudo dpkg-reconfigure slim
重新启动后我发现系统已设置正确的语言。
我决定切换回 lightdm,因为我的屏幕分辨率有问题,运行后
sudo dpkg-reconfigure lightdm
重新启动后一切正常。
也许仅运行 lightdm 的重新配置就正确了。