LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-04-2010, 12:28 AM   #1
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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
 
Old 03-04-2010, 01:28 AM   #2
sahko
Senior Member
 
Registered: Sep 2008
Distribution: Slackware
Posts: 1,041

Rep: Reputation: Disabled
Quote:
Originally Posted by catkin View Post
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?

Last edited by sahko; 03-04-2010 at 01:31 AM.
 
Old 03-04-2010, 01:56 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by sahko View Post
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.
 
Old 03-04-2010, 09:34 AM   #4
Rupa
Member
 
Registered: Apr 2008
Location: Berlin, Germany
Distribution: Slackware, Debian, NetBSD
Posts: 80

Rep: Reputation: 27
Quote:
Originally Posted by catkin View Post
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).
 
1 members found this post helpful.
Old 03-05-2010, 09:16 PM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by Rupa View Post
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.
 
Old 03-05-2010, 11:43 PM   #6
Mol_Bolom
Member
 
Registered: Nov 2008
Location: S.W. Kansas
Distribution: Slackware64 14.0 / 14.2
Posts: 245
Blog Entries: 2

Rep: Reputation: 41
Quote:
Originally Posted by catkin View Post
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?
 
Old 03-06-2010, 10:41 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Marking this thread SOLVED and starting another one with a more appropriate title.
 
  


Reply

Tags
init, lang, locale



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
locale: Cannot Set LC_ALL to default locale: No such file or directory. asym Linux - General 11 10-24-2018 05:54 PM
How to change the locale by setting the system default locale letdoit Slackware 6 08-18-2011 03:34 AM
"locale not supported by Xlib, locale set to C" Irad Linux - Software 3 06-25-2006 03:59 PM
locale: Cannot set LC_ALL to default locale: Invalid argument GadgetWiz Mandriva 1 03-31-2006 11:38 PM
C locale and system locale johnnydangerous Fedora 4 04-11-2005 03:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration