ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Linux locale issue

Linux locale issue

Linux操作系统 作者:wmlm 时间:2016-04-06 08:28:59 0 删除 编辑

案例1:
在
debian下安装程序时,有时候会因为本地设置没有设置好,Per会给出下面的错误提示:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "zh_CN.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

要解决这个问题,其实很简单,只要执行下面几条命令,一切都会OK:

debian:~# apt-get install locales
debian:~# dpkg-reconfigure locales
debian:~# locale

一切都会OK? 不一定,看下面的帖子。

--------------------------------------------------------------------------------------------------------------

 

http : // askubuntu.com/questions/162391/how-do-i-fix-my-locale-issue

 

How do I fix my locale issue?

I am getting this message every time I do something like starting or stopping a service.

perl: warning: Setting locale failed.  

perl: warning: Please check that your locale settings:  

        LANGUAGE = "en_US:en",  

        LC_ALL = (unset),  

        LC_MESSAGES = "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  

(Reading database ... 21173 files and directories currently installed.) 

Removing bind9 ... 

 * Stopping domain name service... bind9                                        [ OK ]

Processing triggers for man-db ...  

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  

How do I fix this error ?

通用的第一招:

First run locale to list what locales currently defined for the current user account:

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

Then generate the missing locale and reconfigure locales to take notice:

$ sudo locale-gen "en_US.UTF-8"
Generating locales...
  en_US.UTF-8... done
Generation complete.
$ sudo dpkg-reconfigure locales
Generating locales...
  en_US.UTF-8... up-to-date
Generation complete.

Now you will not see any errors anymore!

如果第一招不灵:

比如Umair 反馈说: did not work for me – Umair

 

 Ivan Buttinoni又支了一招

@UmairAyub may be you have more than one unknow locale, try this: for y in $(locale | cut -d '=' -f 2| sort |uniq );do locale-gen $y; done It will generate a locale for each definition you have – Ivan Buttinoni 

另外,设置环境变量也可以解决这个问题:

putting to the file /etc/environment:

LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8

 

或者更新到/etc/default/locale

sh -c "echo -e 'LANG=en_US.UTF-8\nLC_ALL=en_US.UTF-8' > /etc/default/locale"

 

如果是在远程连接时报的这个错误,可以使用下面的方法:

This is a common problem if you are connecting remotely, so the solution is to not forward your locale. Edit /etc/ssh/ssh_config and comment out SendEnv LANG LC_* line.

 

On OSX (connecting to ubuntu) it's at /etc/ssh_config

One-liner to do this: sed -e '/SendEnv/ s/^#*/#/' -i /etc/ssh/ssh_config (useful for server provisioning) 

 

update-locale命令做了什么?

here is a command for that:

sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8

It updates /etc/default/locale with provided values.

 

dpkg-reconfigure locales可能什么返回都没有,需要安装语言包:

What worked for me on 12.10 was this:

apt-get install language-pack-en-base  

This was after dpkg-reconfigure locales produced no results.

 

其他还有很多补充,比如使用KDE时怎么办.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/271063/viewspace-2075885/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: TTS 测试笔记
请登录后发表评论 登录
全部评论

注册时间:2008-04-08

  • 博文量
    398
  • 访问量
    3716789