Making Slackware and Slackware Derivative Linux Distros Speak Your Language

Posted by caitlyn on Jan 29, 2009 2:13 AM EDT
O'Reilly Broadcast; By Caitlyn Martin
Mail this story
Print this story

Slackware and some Linux distributions based on Slackware don't include GDM and don't have a graphical tool to set language and locale on the fly. However, if you're willing to edit one or two configuration files and install a few packages you can make Slackware speak your language, working in whatever language you are most comfortable with.

Slackware and some Linux distributions based on Slackware don't include GDM and don't have a graphical tool to set language and locale on the fly. However, if you're willing to edit one or two configuration files and install a few packages you can make Slackware speak your language, working in whatever language you are most comfortable with.



There are four variables that need to be set on almost any modern Linux distribution to fully localize a system:

LANG
LANGUAGE
LINGUAS
LC_ALL



LC_ALL is actually a meta-variable that sets a whole bunch of other variables which start with LC If your goal is to have everything set for what is normal in a given language and country you needn't worry about that. Setting only one or some of these variables results in a mixed language. I've seen how-to articles saying to just set LANG, for example. If the default language is English and you set LANG to es_MX (Spanish for Mexico) the net result is a Spanglish system which probably isn't what most people want.



Where you actually set the variables depends on two things. First, you need to decide if you want to change you system default language and locale or just make changes on a user-by user basis. Second, if you are changing for an individual user you need to know what the default shell is for that user. If you use more than one shell you may need to make the changes in more than one place.



The simpler approach is just changing the default language and locale for the system as a whole. On a vanilla Slackware system they are set in two files localed in /etc/profile.d lang.sh takes care of the default Bourne Again shell (bash) as well as the original Bourne shell (sh) commonly used in system scripts. lang.csh takes care of anyone using csh or tcsh. If you don't use either csh or tcsh on your system you can safely ignore that file.



If you look at /etc/profile.d/lang.sh in your favorite text editor you will see a section that looks like this:



# en_US is the Slackware default locale:
export LANG=en_US


If I wanted my system in Canadian French I could change this section as follows:



# en_US is the Slackware default locale:
export LANG=fr_CA
export LANGUAGE=fr_CA
export LINGUAS=fr_CA
export LC_ALL=fr_CA


You could optionally add .utf8 for Unicode support to each line. Some old applications don't handle Unicode properly. On the other hand, if you use a language that has non-Latin glyphs Unicode is pretty much mandatory. Some Slackware derivatives now use Unicode as part of their default setting even in English. If I'm setting up a system to work in Israeli Hebrew this section would read:



# en_US is the Slackware default locale:
export LANG=he_IL.utf8
export LANGUAGE=he_IL.utf8
export LINGUAS=he_IL.utf8
export LC_ALL=he_IL.utf8


If you're not sure what the language and locale codes are the command:



locale -av



will give you a detailed alphabetical list. It's a very long listing so you may want to pipe the output to more or redirect it to a file.



lang.csh is similar with the setenv command replacing the export command. A stock Slackware lang.csh file will have code that looks like:



# en_US is the Slackware default locale:
setenv LANG en_US


As in lang.sh you replace en_US with the language and locale you want and you include all four variables. Brazilian Portuguese with Unicode support looks like this:



# en_US is the Slackware default locale:
setenv LANG pt_BR.utf8
setenv LANGUAGE pt_BR.utf8
setenv LINGUAS pt_BR.utf8
setenv LC_ALL pt_BR.utf8


Changing language and locale on a user-by-user basis uses exactly the same code. Instead of placing the export commands above in /etc/profile.d/lang.sh you put them in ~/.bashrc ~/.cshrc is used instead of /etc/lang.csh



Once you have your variables set they will take effect at the next login. However you may still not get quite everything in your language of choice. If you use KDE you will also need to install the i18n package for your language. Slackware includes these packages in the repository under kdei. There is a separate i18n package for k3b (CD/DVD burning software) which contains translations for a wide variety of languages. If you use koffice the Slackware repository also includes l10n packages for each supported language. There is also a single glibc i18n package for all locales that I recommend for anyone using a language other than English.



The Slackware extra repository includes a variety of dictionaries for the GNU aspell spellchecker. Language packs and/or dictionaries for Mozilla products (Firefox, Thunderbird, Sunbird and Seamonkey) and for OpenOffice are not in the Slackware repository and have to be obtained from upstream or third party sources. Some Slackware derivatives either offer these packages or, in some cases, fully localized versions of the applications. Spelling dictionaries for spellcheckers other than aspell also aren't in the Slackware repository.



Once the packages for your language and locale are all installed everything should work the next time you launch the application or desktop environment.



If you're coming from a distribution like Ubuntu or Fedora this undoubtedly seems a bit complex. That's probably also true for users of a distro like Zenwalk, which is a Slackware derivative with GDM. If you're comfortable on the command line and with a text editor it really isn't all that difficult. If you're running Slackware it's pretty much assumed that you are either comfortable with the command line or would like to be.

Full Story

  Nav
» Read more about: Story Type: Tutorial; Groups: KDE, Linux, Slackware

« Return to the newswire homepage

This topic does not have any threads posted yet!

You cannot post until you login.