From blog@blog.jwilk.net Sat Jan 12 14:03:31 2013 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Jakub Wilk Subject: Internationalization environment variables Date: Sat, 12 Jan 2013 13:03:31 -0000 Message-Id: <8ed50230a1e2303e98f0122b15b@blog.jwilk.net> Setting `internationalization environment variables`_ is a bit tricky. For example, this:: $ LANG=3Dsv_SE.UTF-8 stat /nonexistent may look like a way to make ``stat(1)`` print the error message in Swedish. Yet there are many ways it could go wrong: 1. ``LC_MESSAGES`` could be set in the environment, overriding ``LANG``. 2. ``LC_ALL`` could be set, overriding both ``LC_MESSAGES`` and ``LANG``. 3. ``LANGUAGE`` could be set, overriding ``LC_ALL``, ``LC_MESSAGES``, and ``LANG``. For extra complexity, ``LANGUAGE`` has no effect if ``LC_MESSAGES`` is effectively set to ``C``. (Also, this variable is a GNUism.) 4. The locale could be simply missing from the system. To make these things a little less intricate, I wrote localehelper_. It's a bit like ``env(1)``, but it takes care of: - unsetting all internationalization variables that weren't explicitly set on the command line; - if needed, generating missing locales (in a temporary location). This does the right thing:: $ localehelper LANG=3Dsv_SE.UTF-8 stat /nonexistent stat: kan inte ta status p=C3=A5 =E2=80=9D/nonexistent=E2=80=9D: Filen e= ller katalogen finns inte .. _internationalization environment variables: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html= #tag_08_02 .. _localehelper: http://jwilk.net/software/localehelper