Opened 7 years ago
Closed 6 years ago
#11193 closed task (fixed)
Locale settings in /etc/profile.d/i18n.sh and /etc/locale.conf
Reported by: | Xi Ruoyao | Owned by: | dj |
---|---|---|---|
Priority: | normal | Milestone: | 8.4 |
Component: | BOOK | Version: | systemd |
Severity: | normal | Keywords: | |
Cc: |
Description ¶
From http://lists.linuxfromscratch.org/pipermail/blfs-dev/2018-September/034916.html:
On 09/26/2018 09:19 AM, Xi Ruoyao via blfs-dev wrote:
In LFS systemd book section 7.7 we create /etc/locale.conf as locale configuation file. But, in BLFS systemd book Chapter 3 section "The Bash Startup Files" we create /etc/profile.d/i18n.sh which sets up the locale for bash. Their settings may be inconsistent and confuse the users (I was confused several times).
We should add a note about this issue in LFS or BLFS book. Now I use an i18n.sh reading /etc/locale.conf (copied from Arch :) to make the settings consistent.
I suppose that we could change /etc/profile.d/i18n.sh to:
if [ -f /etc/locale.conf ]; then
source /etc/locale.conf
else
export LANG=<ll>_<CC>.<charmap><@modifiers>
fi
We may need to update ~/.profile and ~/.bashrc also.
I've used 'source' above to make it clear, but for ~/.profile and i18n.sh is should probably be the dot (.) operator.
-- Bruce
The locale variables need to be exported:
# Begin /etc/profile.d/i18n.sh if [ -s /etc/locale.conf ]; then . /etc/locale.conf else LANG=<ll>_<CC>.<charmap><@modifiers> fi export LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY export LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE export LC_MEASUREMENT LC_IDENTIFICATION LC_ALL # End /etc/profile.d/i18n.sh
Change History (10)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Type: | enhancement → task |
---|
comment:3 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Fetching everything that I know I'll get to in the next few days, per Bruce
comment:4 by , 7 years ago
Do not export unset variables:
# Begin /etc/profile.d/i18n.sh if [ -s /etc/locale.conf ]; then . /etc/locale.conf else LANG=<ll>_<CC>.<charmap><@modifiers> fi for var in LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \ LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE \ LC_MEASUREMENT LC_IDENTIFICATION LC_ALL; do if eval "[ ! -z \${${var}+x} ]"; then export $var fi done unset var # End /etc/profile.d/i18n.sh
comment:5 by , 6 years ago
This is overkill for defaults IMO. I would simply do the equivalent of. /etc/locale.conf && export LANG for systemd. The long export line is likely unneeded if $LC_ALL==$LANG. I can not see a use case for them differing for system use, and I'd likely expect that LC_ALL=$LANG for the system default, but this may be biased as I am only familiar with Germanic and Romance languages (and fluently, only US English at that). If systemd itself can make use of these additional values, and they should differ, then this should be covered in LFS-systemd, else on this page before the commands to create the file. A note explaining that you might want to export additional variables before the commands would be probably be best with the existing links to locale issues.
Additionally, this is only used by users who do not have these values set in ~/.bash{_profile,rc} (or the equivalent for dash or zsh or .profile). Again, I do think a comment is warranted to make it more clear what is expected. Though do as you please on your personal systems, it should probably be considered bad practice to source /etc/locale.conf for the user's .profile on a multilingual system (conversely, it is completely acceptable to use the same values in /etc/skel as defaults if the expected users are to be of common language).
I'm going to do just the systemd separation and wait for more input on the above...specifically for use cases where the individual LC* variables need to differ. Xi (or anybody outside of my bias really), any further input to assist in combating my own ignorance WRT other locales would be greatly appreciated. :-)
For reference:
dj@LFSDT1 [ ~ ]$ echo $LC_ALL dj@LFSDT1 [ ~ ]$ echo $LANG en_US.UTF-8 dj@LFSDT1 [ ~ ]$ 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= dj@LFSDT1 [ ~ ]$
comment:7 by , 6 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
comment:9 by , 6 years ago
Looking at DJ's commit, I do not see what more could be done. We do not need too much fancy in what we publish as example startup files. Shouldn't this ticket be closed as fixed?
comment:10 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Only if they are set. We do not set them. In the else phrase above, is should be
export LANG=<ll>_<CC>.<charmap><@modifiers>