fr_FR.UTF-8
和区域设置C.UTF-8
在区域设置列表(由 给出)中不可用,locale -a
因此我无法使用它们。
这是我尝试添加它们的方法:
$ sudo locale-gen en_US en_US.UTF-8 fr_FR fr_FR.UTF-8
Generating locales...
en_US.ISO-8859-1... up-to-date
en_US.UTF-8... up-to-date
fr_FR.ISO-8859-1... up-to-date
fr_FR.UTF-8... up-to-date
Generation complete.
$ sudo dpkg-reconfigure locales
Generating locales...
en_AG.UTF-8... done
en_AU.UTF-8... done
en_BW.UTF-8... done
en_CA.UTF-8... done
en_DK.UTF-8... done
en_GB.UTF-8... done
en_HK.UTF-8... done
en_IE.UTF-8... done
en_IN.UTF-8... done
en_NG.UTF-8... done
en_NZ.UTF-8... done
en_PH.UTF-8... done
en_SG.UTF-8... done
en_US.ISO-8859-1... up-to-date
en_US.UTF-8... up-to-date
en_ZA.UTF-8... done
en_ZM.UTF-8... done
en_ZW.UTF-8... done
fr_BE.UTF-8... done
fr_CA.UTF-8... done
fr_CH.UTF-8... done
fr_FR.ISO-8859-1... up-to-date
fr_FR.UTF-8... up-to-date
fr_LU.UTF-8... done
Generation complete.
$ export LC_CTYPE=C.UTF-8
$ export LC_COLLATE=C.UTF-8
$ export LC_MESSAGES=fr_FR.UTF-8
$ locale -a
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
C
POSIX
en_US.utf8
编辑1:在我的系统上,locale-gen
可以接受参数,因为它有点旧(包语言环境v2.13)。
无论如何,涉及的其他方法/etc/locale.gen
也不起作用:
$ cat <<-EOF | sudo tee -a /etc/locale.gen
en_US.UTF-8 UTF-8
en_US ISO-8859-1
en_US.ISO-8859-15 ISO-8859-15
fr_FR.UTF-8 UTF-8
fr_FR ISO-8859-1
fr_FR@euro ISO-8859-15
EOF
en_US.UTF-8 UTF-8
en_US ISO-8859-1
en_US.ISO-8859-15 ISO-8859-15
fr_FR.UTF-8 UTF-8
fr_FR ISO-8859-1
fr_FR@euro ISO-8859-15
$ sudo locale-gen
Generating locales...
en_AG.UTF-8... up-to-date
en_AU.UTF-8... up-to-date
en_BW.UTF-8... up-to-date
en_CA.UTF-8... up-to-date
en_DK.UTF-8... up-to-date
en_GB.UTF-8... up-to-date
en_HK.UTF-8... up-to-date
en_IE.UTF-8... up-to-date
en_IN.UTF-8... up-to-date
en_NG.UTF-8... up-to-date
en_NZ.UTF-8... up-to-date
en_PH.UTF-8... up-to-date
en_SG.UTF-8... up-to-date
en_US.ISO-8859-1... up-to-date
en_US.UTF-8... up-to-date
en_ZA.UTF-8... up-to-date
en_ZM.UTF-8... up-to-date
en_ZW.UTF-8... up-to-date
fr_BE.UTF-8... up-to-date
fr_CA.UTF-8... up-to-date
fr_CH.UTF-8... up-to-date
fr_FR.ISO-8859-1... up-to-date
fr_FR.UTF-8... up-to-date
fr_LU.UTF-8... up-to-date
Generation complete.
$ locale -a
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
C
POSIX
en_US.utf8
fr_FR.UTF-8
和区域设置C.UTF-8
在 给出的区域设置列表中仍然不可用locale -a
。
我该怎么做?
答案1
locale-gen
不接受任何命令行参数。相反,它读取/etc/locale.gen
要生成的区域设置列表。
编辑/etc/locale.gen
以取消注释所需的区域设置,然后locale-gen
再次运行。
或者,如果 中没有注释掉的行/etc/locale.gen
,则找到支持的语言环境列表并从那里复制;在 Debian(可能还有相关发行版)中,您可以在 中找到这样的列表/usr/share/i18n/SUPPORTED
。
答案2
请大家不要生我的气:)
我终于找到原因了,我的 $PATH 出了问题:
$ ssh localhost locale -a >/dev/null
$ which -a locale
/home/linuxbrew/.linuxbrew/bin/locale
/usr/bin/locale
$ /home/linuxbrew/.linuxbrew/bin/locale -a >/dev/null
/home/linuxbrew/.linuxbrew/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/home/linuxbrew/.linuxbrew/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
/home/linuxbrew/.linuxbrew/bin/locale: Cannot set LC_COLLATE to default locale: No such file or directory
$ /usr/bin/locale -a >/dev/null
$ /usr/bin/locale -a | egrep -i "(C|fr_FR|en_US).utf-?8"
C.UTF-8
en_US.utf8
fr_FR.utf8