Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
United States

Journal jawtheshark's Journal: Finally a solution to my Locale problems 14

I have most likely already ranted about locales. Locales are deeply flawed, especially under Linux (well, you'll see, not that flawed). They associate a language to a country, like en_US, en_UK, en_CA, fr_FR, fr_LU, de_DE, de_LU... The first part is the "language" part and is lower case, the second part is the territory and it indicates the formatting rules. For example, en_US format to the insane format known as MM/DD/YYYY ;-) For Europeans that's madness. However, there are only a smallish number of locales, which sucks for a certain class of people. I fit in that class, and so does this guy

Think of the American coming over to live in Europe. Of course he wants to have his operating system in English, but he might just be interested in using the local conventions for dates. After all, he might want to have a spreadsheet for his banker with mortgage annuities and the banker will be no doubt confused by the above MM/DD/YYYY format. What he needs is (if he lives in, for example Luxembourg), the en_LU locale. Tough luck, such a thing doesn't exist.

Of course, he's not the only one having this problem. Consider the guy linked to above: he wants his computer related software in English. So do I... You have to understand that I grew up with English-only software (been using software since 1989) and that was normal. My first non-English Windows was hell for me. Software for me is English: final point. This means that I need a en_LU locale, because frankly I don't want imperial units, strange paper format sizes or the dollar as currency symnbol.

In Windows this is relatively easy. Upon install, you select en_GB and the customize it to the formats you want. That works wonderfully. It is still a hack, because the system thinks I'm British with just a strange taste for formats.

Now under Linux I really, really got pissed.... I essentially have the choice between having my formats of choice and an interface in German or French or have the interface in English and have to endure the US formats, or go for the GB and have to live with the pound as currency symbol (or the exotic en_DK, where I get kronas). I cannot get exactly what I want.

I did try what my Finnish friend above did, but somehow it wasn't satisfactory. I needed something else and this is Linux, isn't it? I decided to create my own locale and be done with all these problems. I document this here: I hope to write a real HOW-TO someday, but not today.

The following steps were needed to create the en_LU locale on a Debian/Lenny system. I'll try it later on my Ubuntu 8.10 installation and on my Asus EEE 701 4G which also runs Debian/Lenny.

  • Log in as root.
  • cd /usr/share/i18n/locales
  • Create a new locale from the locale you would use when you live in the country you live in. I have the choice between fr_LU or de_LU. Mostly I more French inclined. So the command is:
    cp fr_LU en_LU
  • Edit en_LU and change the LC_IDENTIFICATION block as follows

    title "English locale for Luxemburg"
    source "jawtheshark.com"
    address "whois jawtheshark.com"
    contact ""
    email "jorg(at)jawtheshark(dot)com"
    tel ""
    fax ""
    language "English"
    territory "Luxemburg"
    revision "1.0"
    date "2009-03-20

    You can also change the comments if you wish (the lines that start with %) The only really important part is: language "English", but we don't want invalid support calls to go off, eh?

  • Now it's time to actually generate this locale. Execute the following command:
    localedef -f UTF-8 -i en_LU en_LU.UTF-8
    It should give no error and no output.
  • cd /etc
  • Well, let's use it.... Now edit locale.gen (which is in the /etc directory, hence the cd /etc/)
  • Simply add a line stating: en_LU.UTF-8 UTF-8
    Technically, you can comment out all other locales if you don't need them. I still keep the en_US.UTF-8 UTF-8, just in case. I don't think is needed though.
  • Now we need to re-generate the system locales. Execute: locale-gen. The output should look like this:

    Generating locales (this might take a while)...
    en_LU.UTF-8... done
    en_US.UTF-8... done
    Generation complete.

  • Set the newly generated locale as default. For that edit /etc/default/locale and change the content to: LANG="en_LU.UTF-8"
  • Oddly enough the papersize is not automatically updated (there must be an automatic way, I just didn't find it. Since we use the A4 paper format issue the following command: echo -n a4 > /etc/papersize
  • We're done... I rebooted as a Login/Logout didn't seem enough....

A final remark: all printers you have created using the letter format will still "think" they are letter. Either kill them and reinstall them, or change the setting.

I can now finally enjoy an English desktop with local formatting.

Update on OpenOffice.org2
I cheered to early. Everything in Gnome seems okay, but OpenOffice defaults to en_US. Why I do not know. I tried killing ~/.openoffice.org2. The locale is really set correctly since the locale output is:

LANG=en_LU.UTF-8
LC_CTYPE="en_LU.UTF-8"
LC_NUMERIC="en_LU.UTF-8"
LC_TIME="en_LU.UTF-8"
LC_COLLATE="en_LU.UTF-8"
LC_MONETARY="en_LU.UTF-8"
LC_MESSAGES="en_LU.UTF-8"
LC_PAPER="en_LU.UTF-8"
LC_NAME="en_LU.UTF-8"
LC_ADDRESS="en_LU.UTF-8"
LC_TELEPHONE="en_LU.UTF-8"
LC_MEASUREMENT="en_LU.UTF-8"
LC_IDENTIFICATION="en_LU.UTF-8"
LC_ALL=

I need to look up what LC_ALL is but, essentially it looks good. I'll try to find a acceptable solution for OpenOffice.org2 though.

Update on OpenOffice.org2
Doesn't look as if it is possible, read this and weep. You can change "only" two settings to have the desired effect.

This discussion has been archived. No new comments can be posted.

Finally a solution to my Locale problems

Comments Filter:
  • I have hated US date formats so deeply, that I write nearly all dates as "March 20, 2009", rather than surrender to the notion that this somehow equals 3/20/09.

    And to have my machine criticise me - as I type organise? It's mad'ning!

    I need UK keyboards and dictionaries (where did @ and ~ go?) with US papersizing and currency.

    Thanks for you tips. Perhaps I'll game up an en_EX.

    • I still have the OpenOffice problem.... So it's not fully fixed. I still wonder who came up with the "Locale" concept. It's most likely someone who only knows one language. It's maddening.
      • most likely someone who only knows one language.

        I see you've narrowed your blame down to an American. ;-)
        • ...or a Frenchman ;-)

          Seriously: there are plenty of Germans only speaking German (especially when a bit older), and I don't think that people from the UK know all that much languages either. For the French, well, I notice that people with a University degree usually speak English. The rest: forget it.

          • There are many French who understand English - but won't deign to do so.

            • Hehe, true enough....
            • by ces ( 119879 )

              Of course without the English, Canadians, and Americans the French would likely be speaking German.

              • Oh, come on... Not that one again... It's so saddening that Americans have to fall back to that one each and every time. You're not entitled to eternal gratitude. (At least, you were fair enough to include the English and the Canadians)

                If you really want to go that way, think about what your nice little revolution back in the day would have been without the French helping you out.

                Stop it already, adn I'm not even French...

                • by ces ( 119879 )

                  It was just a little joke.

                  Good point about the French being friends of the US for much longer than the UK has.

                  • I know it was a joke.

                    It is much less a joke if you happen to be in a bar in the US and the guy next to you actually says this in your face and means it. Especially when he thinks that Luxembourg is in Germany.

                    That's why I'm allergic to the joke.... On an Internet forum, it's all fun and games. I actually did encounter this more than once in the US.

              • You worry 'bout the Sun
                What's the use in worrying
                'Bout the big old Sun?

                You worry 'bout the rain
                The rain keeps fallin'
                Just the same.

                You worry when
                The one you need
                Has found sombody new...

                But the world keeps going 'round.

            • by gmhowell ( 26755 ) *

              There are many French who understand English - but won't deign to do so.

              The term for these people is 'Quebecois'.

    • by Tet ( 2721 ) *

      I need UK keyboards and dictionaries (where did @ and ~ go?) with US papersizing and currency.

      Heh. I'm the exact opposite. I need a US keyboard layout (double quotes being a shifted-2 is a deal breaker for me when it comes to using a UK keyboard), but of course, being in the civilized world, I need sensible paper sizes...

      • Well, but luckily for you, keyboard layouts and locales are independent ;-) (Imagine the hell if those would be interlinked too!)

Arithmetic is being able to count up to twenty without taking off your shoes. -- Mickey Mouse

Working...