Solve the Problem of modifying locale in Ubuntu

Source: Internet
Author: User
Tags i18n
This article focuses on & ldquo; installing Chinese Language Pack & rdquo; & ldquo; UbuntuServer Chinese Questions & rdquo;, & ldquo; changing the language environment of Ubuntu & rdquo;, & ldquo; ubuntulocale setting & rdquo;, & ldquo; cannotchangelocale (zh_CN.UTF-8) & rdquo;, & ldquo; Linux Chinese garbled & rdquo ;,

This article is aimed at the problem of "Ubuntu installation Chinese Language Pack" "Ubuntu Server Chinese problems", "Ubuntu change language environment", "Ubuntu locale settings", "cannot change locale (zh_CN.UTF-8) "," Linux Chinese garbled characters "," Linux Character Set modification ", and" Linux garbled solutions "provide an all-in-one solution. If the system displays Chinese exceptions, such as Chinese garbled characters, you can refer to this article. For how to modify the CentOS system, refer to the description at the end of the article.

Problem description

The terminal displays Chinese normally, and the application displays Chinese exceptions.

Error Message

1 sudo dpkg-reconfigure locales

Perl: warning: Setting locale failed.
Perl: warning: Please check that your locale settings:
LANGUAGE = "zh_CN: zh: en_US: en ",
LC_ALL = "zh_CN.UTF-8 ",
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
/Bin/bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8)
Generating locales...
En_US.UTF-8.../usr/sbin/locale-gen: line 177: warning: setlocale: LC_ALL: cannot change locale (zh_CN.UTF-8)
Up-to-date
Generation complete.

1 man locale

Man: can't set the locale; make sure $ LC _ * and $ LANG are correct

1 $ 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 = zh_CN.UTF-8
LANGUAGE = zh_CN: zh: en_US: en
LC_CTYPE = "zh_CN.UTF-8"
LC_NUMERIC = "zh_CN.UTF-8"
LC_TIME = "zh_CN.UTF-8"
LC_COLLATE = "zh_CN.UTF-8"
LC_MONETARY = "zh_CN.UTF-8"
LC_MESSAGES = "zh_CN.UTF-8"
LC_PAPER = "zh_CN.UTF-8"
LC_NAME = "zh_CN.UTF-8"
LC_ADDRESS = "zh_CN.UTF-8"
LC_TELEPHONE = "zh_CN.UTF-8"
LC_MEASUREMENT = "zh_CN.UTF-8"
LC_IDENTIFICATION = "zh_CN.UTF-8"
LC_ALL =

1 $ localectl list-locales

C.UTF-8
En_US.utf8
Zh_CN.utf8

Solution

To properly display Chinese Characters in an application, the following three variables should be used,

123 LANG=zh_CN.UTF-8   LANGUAGE=zh_CN:zh:en_US:en   LC_ALL=LC_ALL=zh_CN.UTF-8

But the problem is that "LC_ALL to default locale: No such file or directory" and "LC_ALL: cannot change locale (zh_CN.UTF-8)", so reinstall the Chinese Language Pack.

Run the following command:

1 sudo apt-get -y install language-pack-zh-hans

Or

1 sudo apt-get -y install language-pack-zh-hans language-pack-zh-hans-base

If you want to support traditional Chinese characters, run

1 sudo apt-get -y install language-pack-zh-hant

Or

1 sudo apt-get -y install language-pack-zh-hant language-pack-zh-hant-base

Run the locale command to set the current locale environment.

1 locale

Related Files and references

Related manuals: man locale (1), locale (5), locale (7)

Related Files:/usr/share/i18n/SUPPORTED

Related commands:

Locale -- all-locales list all supported locale in the current system

Localectl list-locales list all available locale in the current system

Localectl set-locales LOCALE... modify locale in the current system. It has the same function as locale and is the same as the three variables mentioned above in export.

For CentOS, you can directly edit the/etc/sysconfig/i18n file and set LANG = "en_US.UTF-8" to LANG = "zh_CN.UTF-8". In addition, the locale command under CentOS is displayed as follows:

1 # locale

LANG = en_US.UTF-8
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 =

LC_ALL = is null, but it does not indicate that it is incorrect. LC_ALL = is actually equal to LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_MESSAGES, LC_NUMERIC, and LC_TIME. For more information, see locale (7 ).

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2015-08/122501.htm

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.