You are not logged in.

#1 2022-08-22 16:39:47

Firestar
Member
From: Beijing, China
Registered: 2021-07-19
Posts: 115
Website

[Solved] My bash do not export LANG=en_US.UTF-8

Hello everyone.

I have a newly installed Archlinux KDE with `zh_CN.UTF-8` as default because I am Chinese, but I want my bash exports English for convenience. So I added

export LANG=en_US.UTF-8

in my `.bashrc`. But after I source it, the shell still outputs Chinese. On the other hand, although I uncommented both en_US and zh_CN in `/etc/locale.gen`, it uses English by default, I manually changed it to zh_CN on KDE systemsettings.

[firestar@ArchLinux ~]$ 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=

[firestar@ArchLinux ~]$ cat /etc/locale.conf
LANG=en_US.UTF-8

[firestar@ArchLinux ~]$ cat ~/.config/plasma-localerc
[Formats]
LANG=zh_CN.UTF-8

[Translations]
LANGUAGE=zh_CN:en_US

PS: I first know that this forum does not support markdown syntax

Last edited by Firestar (2022-08-23 06:43:33)


Write programs that do one thing and do it well.
Write programs to work together.
Write programs to handle text streams, because that is a universal interface.

Offline

#2 2022-08-22 16:44:16

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,453
Website

Re: [Solved] My bash do not export LANG=en_US.UTF-8

Firestar wrote:

... after I source it, the shell still outputs Chinese

The bash shell itself still will, yes.  But do utilities started from that shell session use English?  In order to change the language for the shell itself, you need to export the LANG setting in the environment in which the bash shell is launched.  Or, ash a test, does the following do what you want:

export LANG=en_US.UTF-8
exec bash

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2022-08-22 16:57:58

Firestar
Member
From: Beijing, China
Registered: 2021-07-19
Posts: 115
Website

Re: [Solved] My bash do not export LANG=en_US.UTF-8

No, it still export Chinese. Like this:

[firestar@ArchLinux ~]$ export LANG=en_US.UTF-8
[firestar@ArchLinux ~]$ exec bash
[firestar@ArchLinux ~]$ sudo pacman -Syyu
:: 正在同步软件包数据库...
 core                                  158.2 KiB  2.01 MiB/s 00:00 [####################################] 100%
 extra                                1765.8 KiB  6.56 MiB/s 00:00 [####################################] 100%
 community                               6.8 MiB  5.59 MiB/s 00:01 [####################################] 100%
:: 正在进行全面系统更新...
 今日无事可做

Write programs that do one thing and do it well.
Write programs to work together.
Write programs to handle text streams, because that is a universal interface.

Offline

#4 2022-08-22 17:01:32

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,516
Website

Re: [Solved] My bash do not export LANG=en_US.UTF-8

Did you generate the English locales?

$ grep ^en_US.UTF-8 /etc/locale.gen
# locale-gen

Last edited by schard (2022-08-22 17:02:55)


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#5 2022-08-22 17:12:25

Firestar
Member
From: Beijing, China
Registered: 2021-07-19
Posts: 115
Website

Re: [Solved] My bash do not export LANG=en_US.UTF-8

although I uncommented both en_US and zh_CN in `/etc/locale.gen`

[firestar@ArchLinux ~]$ grep ^en_US.UTF-8 /etc/locale.gen
en_US.UTF-8 UTF-8  
[firestar@ArchLinux ~]$ sudo locale-gen
Generating locales...
  en_US.UTF-8... done
  zh_CN.UTF-8... done
Generation complete.

Write programs that do one thing and do it well.
Write programs to work together.
Write programs to handle text streams, because that is a universal interface.

Offline

#6 2022-08-22 17:34:29

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 2,516
Website

Re: [Solved] My bash do not export LANG=en_US.UTF-8

What happens on

LANG=C bash

or

LANG=en_US.UTF-8 bash

Last edited by schard (2022-08-22 17:35:39)


Inofficial first vice president of the Rust Evangelism Strike Force

Offline

#7 2022-08-22 18:25:24

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 73,024

Re: [Solved] My bash do not export LANG=en_US.UTF-8

LANGUAGE= LANG=en_US.UTF-8 bash

If that doesn't work

bash -ixc echo > /tmp/bash.dbg 2>&1

and post that file.

Online

#8 2022-08-23 01:32:47

Firestar
Member
From: Beijing, China
Registered: 2021-07-19
Posts: 115
Website

Re: [Solved] My bash do not export LANG=en_US.UTF-8

`LANG=` doesn't work but `LANGUAGE=` can

[firestar@ArchLinux ~]$ LANG=en_US.UTF-8 bash
[firestar@ArchLinux ~]$ sudo pacman -Syyu
:: 正在同步软件包数据库...
 core                                  158.2 KiB  2.45 MiB/s 00:00 [####################################] 100%
 extra                                1765.8 KiB  6.23 MiB/s 00:00 [####################################] 100%
 community                               6.8 MiB  5.44 MiB/s 00:01 [####################################] 100%
:: 正在进行全面系统更新...
 今日无事可做
[firestar@ArchLinux ~]$ LANGUAGE= LANG=en_US.UTF-8 bash
[firestar@ArchLinux ~]$ sudo pacman -Syyu
:: Synchronizing package databases...
 core                                  158.2 KiB  2.31 MiB/s 00:00 [####################################] 100%
 extra                                1765.8 KiB  14.0 MiB/s 00:00 [####################################] 100%
 community                               6.8 MiB  6.86 MiB/s 00:01 [####################################] 100%
:: Starting full system upgrade...
 there is nothing to do
[firestar@ArchLinux ~]$ bash -ixc echo > /tmp/bash.dbg 2>&1
[firestar@ArchLinux ~]$ cat /tmp/bash.dbg
+ [[ himxBHc != *i* ]]
+ [[ -n :0 ]]
+ shopt -s checkwinsize
+ PS1='[\u@\h \W]\$ '
+ case ${TERM} in
+ PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
+ '[' -r /usr/share/bash-completion/bash_completion ']'
+ export LANG=en_US.UTF-8
+ LANG=en_US.UTF-8
+ echo

So I changed `LANG=` to `LANGUAGE=` in my `.bashrc` and it works!

Last edited by Firestar (2022-08-23 01:38:22)


Write programs that do one thing and do it well.
Write programs to work together.
Write programs to handle text streams, because that is a universal interface.

Offline

#9 2022-08-23 03:38:23

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

Re: [Solved] My bash do not export LANG=en_US.UTF-8

You don't need to keep doing

pacman -Syyu

You almost always just need

pacman -Syu

This will update pacman's information if it is out of date, but it won't download it unnecessarily. This should almost always do everything you need.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#10 2022-08-23 05:56:01

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 73,024

Re: [Solved] My bash do not export LANG=en_US.UTF-8

LANGUAGE=zh_CN:en_US

https://wiki.archlinux.org/title/Locale … ck_locales

Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Do you btw. use grub and have issues w/ the zh_CN locale on grub-mkconfig?
https://bbs.archlinux.org/viewtopic.php?id=279042 seems to indicate a bug in one of the localization files, but I'm pretty sure that the OP there doesn't speak english - at all.

Online

#11 2022-08-23 07:05:30

Firestar
Member
From: Beijing, China
Registered: 2021-07-19
Posts: 115
Website

Re: [Solved] My bash do not export LANG=en_US.UTF-8

I used other distros before and they supports `LANG`, so I was curious to find that archlinux does not.

I have reported in https://bbs.archlinux.org/viewtopic.php?id=279042: **It is strange that although locale-gen can generate other locales than English, the locale.conf can only use English.**

PS: Isn't there a button or something to let others know that the problem is solved and which post is the solution? That's bad. I recommend Arch Linux Forum have a better functionality as Manjaro Forum (**build by discourse: https://github.com/discourse/discourse **) or Stackoverflow which supports markdown, translations, tags and many other things.

Last edited by Firestar (2022-08-23 07:14:58)


Write programs that do one thing and do it well.
Write programs to work together.
Write programs to handle text streams, because that is a universal interface.

Offline

#12 2022-08-23 07:17:59

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 73,024

Re: [Solved] My bash do not export LANG=en_US.UTF-8

LANG is perfectly supported, but LANUGAGE is as well and does something different - this has nothing to do with the distribution.
The LANGUAGE variable was simply "in the way".

Online

Board footer

Powered by FluxBB