LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   How to set the system locale? (https://www.linuxquestions.org/questions/slackware-14/how-to-set-the-system-locale-793063/)

catkin 03-04-2010 12:28 AM

How to set the system locale?
 
Hello :)

Where is the system locale set?

When /etc/profile is run it sources /etc/profile.d/lang.sh which sets envar $LANG but /etc/profile is only used by login shells so -- AFAIK -- modifying $LANG in /etc/profile.d/lang.sh will not change the system locale for processes started by the boot scripts.
  • There are no *locale* files under /etc.
  • /etc/inittab has nothing about locale.
  • man init has nothing about locale.
  • man 7 locale describes locale.h and its usage.
  • man 5 locale describes the format of locale files.
  • /sbin/init (as investigated using the strings command) may call nl_langinfo but man nl_langinfo only describes how to query the locale, not where it is set.

Best

Charles

sahko 03-04-2010 01:28 AM

Quote:

Originally Posted by catkin (Post 3885049)
modifying $LANG in /etc/profile.d/lang.sh will not change the system locale for processes started by the boot scripts.

Why do you want to change that?

catkin 03-04-2010 01:56 AM

Quote:

Originally Posted by sahko (Post 3885099)
Why do you want to change that?

Good question, especialy as /etc/profile.d/lang.sh includes the comment:
Code:

# There is also support for UTF-8 locales, but be aware that
# some programs are not yet able to handle UTF-8 and will fail to
# run properly.  In those cases, you can set LANG=C before
# starting them.  Still, I'd avoid UTF unless you actually need it.

Unfortunately it is atually needed, for Bacula. According to the Bacula Main Reference (available as PDF or HTML at http://www.bacula.org/en/?page=documentation), in the "13.1 Critical Items" section: "Bacula assumes all filenames are in UTF-8 format. This is important when saving the filenames to the catalog. For Win32 machine, Bacula will automatically convert from Unicode to UTF-8, but on Unix, Linux, *BSD, and MacOS X machines, you must explicitly ensure that your locale is set properly. Typically this means that the bf LANG environment variable must end in .UTF-8. An full example is en US.UTF-8. The exact syntax may vary a bit from OS to OS, and exactly how you define it will also vary."

It would be nice to set it for Bacula only but that would require front-ending a lot of executables and I'm not confident of being able to identify them all. Actually it would be very nice because setting $LANG to en_GB.UTF-8 (the closest available for Indian English) is already causing breakage:
  • mrxvt (terminal emulator) positions the CLI cursor incorrectly and cannot do command line editing. It does not support UTF-8 so that's fair enough. Unfortuantely I'll have to change terminal emulator and that is likely to require a lot of time to get the new one set up and working nicely.
  • dvd+rw-format is outputting unexpected characters which broke the locally written backup script until fixed with export LANG=en_US.

Rupa 03-04-2010 09:34 AM

Quote:

Originally Posted by catkin (Post 3885123)
Good question, especialy as /etc/profile.d/lang.sh includes the comment:
Code:

# There is also support for UTF-8 locales, but be aware that
# some programs are not yet able to handle UTF-8 and will fail to
# run properly.  In those cases, you can set LANG=C before
# starting them.  Still, I'd avoid UTF unless you actually need it.


This statement really is outdated nowadays. It's just the other way round: you SHOULD use UTF-8 whereever it's possible, and - believe me - you want it. ;-)

Just put "en_US.UTF-8" in there (or whatever language your're using). And add "vt.default_utf8=1" to your kernel boot parameters ('append=" ..."' in lilo.conf).

catkin 03-05-2010 09:16 PM

Quote:

Originally Posted by Rupa (Post 3885608)
This statement really is outdated nowadays. It's just the other way round: you SHOULD use UTF-8 whereever it's possible, and - believe me - you want it. ;-)

Just put "en_US.UTF-8" in there (or whatever language your're using). And add "vt.default_utf8=1" to your kernel boot parameters ('append=" ..."' in lilo.conf).

Thanks Rupa :)

Surely UTF-8 is the way to go but when Slackware comes with a warning like that, I anticipate some pain!

I've done as you suggested. Is that "vt" as in "virtual terminal"?

I'm still puzzled about how locale is set by init and hence for processes started during boot.

Mol_Bolom 03-05-2010 11:43 PM

Quote:

Originally Posted by catkin (Post 3887774)
Surely UTF-8 is the way to go but when Slackware comes with a warning like that, I anticipate some pain!

I have used utf8 for some time now, and the only programs I've had issues with are a few ncurses based programs. However, I only use a very few programs, so who am I to say anything? ;)

catkin 03-06-2010 10:41 AM

Marking this thread SOLVED and starting another one with a more appropriate title.


All times are GMT -5. The time now is 01:33 AM.