我在设置语言环境时遇到了一些问题。我在输入以下内容时遇到了类似这样的错误区域设置在终端:
$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_ALL to default locale: No such file or directory
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=en_US.UTF-8
我不知道我做错了什么,但我需要你们的帮助。当我在终端中输入 locale-gen 时,我收到一个错误:
Generating locales (this might take a while)...
en_US.UTF-8...failed to set locale!
[error] cannot open locale definition file `en_GB': No such file or directory
done
Generation complete.
我找到了一个解决方案,不知怎么的,我自己想出来的。我删除了 /etc/locale.gen 中最后一行的 #。删除之前,它如下所示:
# aa_DJ ISO-8859-1
# aa_DJ.UTF-8 UTF-8
# aa_ER UTF-8
# aa_ER@saaho UTF-8
...
# zu_ZA ISO-8859-1
# zu_ZA.UTF-8 UTF-8
en_US.UTF-8 UTF-8
我把最后一行改成这样:
# en_US.UTF-8 UTF-8
我不知道我是否做错了什么,但当我这样做时,错误解决了。请告诉我我是否做错了什么。之后我尝试重新配置语言环境,但当我尝试执行以下操作时,我收到另一个错误:
$sudo dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "",
LC_ALL = "en_US.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
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_ALL to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory
当我尝试使用以下命令更改 LC_ALL 时,还出现一个错误:
$export LC_ALL="en_US.UTF-8 UTF-8"
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory
我收到错误,但 LC_ALL 发生了变化。我不知道我的语言环境设置发生了什么,但看起来我真的搞砸了。我应该怎么做才能修复所有这些问题?
答案1
确保您的语言环境存在:
locale -a
如果在列表中没有看到您的语言环境,请使用:
sudo locale-gen en_US
sudo locale-gen en_US.UTF-8
然后通过以下方式将您的语言环境更新为现有语言环境:
sudo update-locale LC_ALL=en_US.UTF-8
通过以下方式应用更改:
. /etc/default/locale
我的语言环境:
$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=uk_UA.UTF-8
LC_TIME=uk_UA.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=uk_UA.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=uk_UA.UTF-8
LC_NAME=uk_UA.UTF-8
LC_ADDRESS=uk_UA.UTF-8
LC_TELEPHONE=uk_UA.UTF-8
LC_MEASUREMENT=uk_UA.UTF-8
LC_IDENTIFICATION=uk_UA.UTF-8
LC_ALL=
设置当前会话的区域设置:
$ export LC_ALL=en_US.UTF-8
$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US
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=en_US.UTF-8
你也可以尝试
$ sudo apt purge locales && sudo apt install locales