Simple solution to Ubuntu change locale problem

Source: Internet
Author: User
Tags i18n locale locale setting

This article addresses the issue of "Ubuntu Install Chinese language Pack" "Ubuntu Server Chinese Problem", "Ubuntu change locale", "Ubuntu locale setting", "Cannot changes locale" (ZH_CN. UTF-8) "," Linux Chinese garbled "," modification of the Linux character set "," Linux garbled Solution "and other issues, provide a one-stop solution. If the system displays Chinese exceptions, such as displaying garbled characters in Chinese, you can refer to this article. Please refer to the description at the end of the article for modifications to the CentOS system.

Problem description

The terminal display Chinese normal, the application inside display Chinese exception.

Error performance

$ 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 "
is supported and installed on your system.
Perl:warning:Falling 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)
Generation complete.

$ man Locale

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

$ 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    
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 "   

$ localectl List-locales


Problem-solving approach

To achieve the purpose of the normal display of Chinese characters in the application, the following three variables should be shown below.

Lang=zh_cn. UTF-8 language=zh_cn:zh:en_us:en LC_ALL=LC_ALL=ZH_CN. UTF-8

But the problem is "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.

Execute the following command

sudo apt-get-y install Language-pack-zh-hans


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

If you want to support traditional characters, perform

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


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

Then perform the locale command to set the current locale environment


Related Documents and references

Related manuals: Man locale (1), Locale (5), Locale (7)

Related documents:/usr/share/i18n/supported

Related commands:

Locale--all-locales lists all supported locales in the current system

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

Localectl set-locales LOCALE ... Modifies the locale in the current system, same as the locale function, same as the three variables mentioned in export

For CentOS, you can edit the/etc/sysconfig/i18n file directly, and the lang= "en_US. UTF-8 "set to Lang=" ZH_CN. UTF-8 ", in addition to the following, the display result of the CentOS locale command is as follows:

# 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 "

Where lc_all= is empty, but it does not mean that it is not right here, but that lc_all= is actually equal to Lc_collate, Lc_ctype, Lc_monetary, Lc_messages, Lc_numeric, lc_time, see locale ( 7).

This article is from "Communication, My Favorites" blog, please make sure to keep this source

Simple solution to Ubuntu change locale problem

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: 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.