Switching the System Language in Ubuntu
Today, after switching my display manager to ly, I noticed that the default language in the terminal was Chinese. I want to change it back to English. Since I'm using the labwc environment, I don't want to switch to Gnome and click on the GUI settings. Or, if your server doesn't have a graphical interface, changing the system language from the command line is useful.
The following describes how to switch the system language via the command line (demonstrating switching from English to Chinese and vice versa):
1. Check the current language setting first
1➜ ~ locale
2LANG=en_US.UTF-8
3LANGUAGE=
4LC_CTYPE="en_US.UTF-8"
5LC_NUMERIC=en_US.UTF-8
6LC_TIME=en_US.UTF-8
7LC_COLLATE="en_US.UTF-8"
8LC_MONETARY=en_US.UTF-8
9LC_MESSAGES="en_US.UTF-8"
10LC_PAPER=en_US.UTF-8
11LC_NAME=en_US.UTF-8
12LC_ADDRESS=en_US.UTF-8
13LC_TELEPHONE=en_US.UTF-8
14LC_MEASUREMENT=en_US.UTF-8
15LC_IDENTIFICATION=en_US.UTF-8
16LC_ALL=
As can be seen above, the current system language is English. Therefore, currency, measurements, addresses, phone numbers, and times will all be displayed in English. Many programs rely on this configuration, including glibc.
2. Re-select the system language
1➜ ~ sudo dpkg-reconfigure locales
2Generating locales (this might take a while)...
3en_AG.UTF-8... done
4en_AU.UTF-8... done
5en_BW.UTF-8... done
6en_CA.UTF-8... done
7en_DK.UTF-8... done
8en_GB.UTF-8... done
9en_HK.UTF-8... done
10en_IE.UTF-8... done
11en_IL.UTF-8... done
12en_IN.UTF-8... done
13en_NG.UTF-8... done
14en_NZ.UTF-8... done
15en_PH.UTF-8... done
16en_SG.UTF-8... done
17en_US.UTF-8... done
18en_ZA.UTF-8... done
19en_ZM.UTF-8... done en_ZW.UTF-8... done
20zh_CN.UTF-8... done
21zh_SG.UTF-8... done
22Generation complete.
A TUI interface will pop up. First, you need to select the target supported languages. You can select multiple languages.
Select the default language
3. Configuration Test
After exiting and restarting, test again. As shown below, some configurations have been switched to Chinese.
1➜ ~ locale
2LANG=zh_CN.UTF-8
3LANGUAGE=
4LC_CTYPE="zh_CN.UTF-8"
5LC_NUMERIC=en_US.UTF-8
6LC_TIME=en_US.UTF-8
7LC_COLLATE="zh_CN.UTF-8"
8LC_MONETARY=en_US.UTF-8
9LC_MESSAGES="zh_CN.UTF-8"
10LC_PAPER=en_US.UTF-8
11LC_NAME=en_US.UTF-8
12LC_ADDRESS=en_US.UTF-8
13LC_TELEPHONE=en_US.UTF-8
14LC_MEASUREMENT=en_US.UTF-8
15LC_IDENTIFICATION=en_US.UTF-8
16LC_ALL=
At this time, enter the date
command to view it, it is still in English format. Because LC_TIME=en_US.UTF-8
1➜ ~ date
2Thu Jul 13 04:27:39 PM CST 2023
Testing by changing LC_TIME=zh_CN.UTF-8
, the time is converted to Chinese format:
1➜ ~ date
22023 July 13 Thursday 16:31:57 CST
3➜ ~ cat /etc/default/locale
4LANG=zh_CN.UTF-8
5LC_NUMERIC=en_US.UTF-8
6LC_TIME=zh_CN.UTF-8
7LC_MONETARY=en_US.UTF-8
8LC_PAPER=en_US.UTF-8
9LC_NAME=en_US.UTF-8
10LC_ADDRESS=en_US.UTF-8
11LC_TELEPHONE=en_US.UTF-8
12LC_MEASUREMENT=en_US.UTF-8
13LC_IDENTIFICATION=en_US.UTF-8
14➜ ~ cat /etc/default/locale |grep LC_TIME
15LC_TIME=zh_CN.UTF-8
16➜~date
17Thursday, July 13, 2023 16:32:38 CST
As you can see, the different configuration options control different areas, so I won't list them all. I usually choose to change everything to English.
Command example:
- vim
%s/aaa/bbb/g
- sed
1sudo sed -i s/zh_CN/en_US/g /etc/default/locale
How do I find these keywords? Please see
1
2➜ ~ locale -a
3C
4C.utf8
5en_AG
6en_AG.utf8
7en_AU.utf8
8en_BW.utf8
9en_CA.utf8
10en_DK.utf8
11en_GB.utf8
12en_HK.utf8
13en_IE.utf8
14en_IL
15en_IL.utf8
16en_IN
17en_IN.utf8
18en_NG
19en_NG.utf8
20en_NZ.utf8
21en_PH.utf8
22en_SG.utf8
23en_US.utf8
24en_ZA.utf8
25en_ZM
26en_ZM.utf8
27en_ZW.utf8
28POSIX
29zh_CN.utf8
30zh_SG.utf8
Note, remember to exit tmux when testing session (will remember the session and affect the comparison effect), restart the system when it is time to restart.
Copyright statement:
- All content that is not sourced is original., please do not reprint without authorization (because the typesetting is often disordered after reprinting, the content is uncontrollable, and cannot be continuously updated, etc.);
- For non-profit purposes, to deduce any content of this blog, please give the relevant webpage address of this site in the form of 'source of original text' or 'reference link' (for the convenience of readers).
See Also:
- Speeding Up Ubuntu Boot
- Snipe it asset management system installation and use
- Manually Upgrading LibreOffice in Ubuntu
- Ubuntu 22.10 connection bluetooth headset error 'br-connection-profile-unavailable solution'
- Ubuntu connects AirPods headphones
- Set Alacritty as the Default Terminal in Ubuntu
- Ubuntu Change Login Wallpaper
- Batch Convert PNG Images to WebP
- Install the latest version of Git from source on Ubuntu
- Ubuntu install WeChat