Debian

將語言環境更改為 en_US.UTF-8 但程序仍嘗試翻譯成其他語言

  • August 9, 2018

我將系統區域設置更改為en_US.UTF-8with dpkg-reconfigure localeslocale命令輸出:

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

/etc/default/locale我有以下內容:

LANG=en_US.UTF-8

此外,/etc/locale.gen確實只包含en_US.UTF-8 UTF-8.

unattended-upgrades每天早上執行從/etc/cron.daily/apt-compat在我的系統日誌中產生以下錯誤:

apt.systemd.daily[3829]: --- Logging error ---
apt.systemd.daily[3829]: Traceback (most recent call last):
apt.systemd.daily[3829]:   File "/usr/lib/python3.5/logging/__init__.py", line 983, in emit
apt.systemd.daily[3829]:     stream.write(msg)
apt.systemd.daily[3829]: UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in position 43: ordinal not in range(128)
apt.systemd.daily[3829]: Call stack:
apt.systemd.daily[3829]:   File "/usr/bin/unattended-upgrade", line 1538, in <module>
apt.systemd.daily[3829]:     main(options)
apt.systemd.daily[3829]:   File "/usr/bin/unattended-upgrade", line 1219, in main
apt.systemd.daily[3829]:     logging.info(_("Allowed origins are: %s"), allowed_origins)
apt.systemd.daily[3829]: Message: 'erlaubte Urspr\xfcnge sind: %s'
apt.systemd.daily[3829]: Arguments: (['origin=Debian,codename=stretch,label=Debian-Security'],)

系統試圖翻譯Allowed origins are: %s成德語版本erlaubte Ursprünge sind: %s,其中包含一個特殊的字元ü。經過一番研究,我發現帶有翻譯的文件可以在這裡找到:/usr/share/locale/de/LC_MESSAGES/unattended-upgrades.mo.

為什麼apt/unattended-upgrades嘗試將英語翻譯成德語,因為我已經將語言環境更改為正確的英語值?我怎樣才能阻止這種行為?

通過再次發出以下命令解決了該問題:

dpkg-reconfigure locales
localectl set-locale LANG=en_US.UTF-8 LANGUAGE=en_US:en

引用自:https://unix.stackexchange.com/questions/460280