Feedback

type to search

How should I change the locale for an Xfce session in Squeeze?

Asked by [ Editor ] , Edited by Gerfried Fuchs [ Editor ]

When running Lenny, I used to set locales for specific users running Xfce by copying /etc/xdg/xfce4/xinitrc to the users' home directory (under ~./config/xfce4) and then adding a simple export LANG=whatever to that file. That always worked AFAIR. 

Unfortunately, so far I couldn't do the same in Squeeze, and for some reason that eludes me, it refuses to set the LANG variable.

By adding the following lines to ~./config/xfce4/xinitrc, I could verify that xinitrc is being executed, and that the variable is being set as it should.

export LANG=es_ES.UTF-8
echo $LANG > /tmp/xinitrc

However, something else must be overwriting it, because the whole environment is still in English, and the LANG variable shows en_US.UTF-8 after the Xfce session has been started.

I've also found some tips suggesting the use of the ~/.xsessionrc file for this purpose, which is seemingly "the Debian way" of doing it. So, if I create that file with the following contents, I can verify that is being called and that it's doing what it should (changing the variable), but after Xfce has started, everything is still in English and LANG remains set to en_US.UTF-8.

#!/bin/sh 

export LANG=es_ES.UTF-8
echo $LANG > /tmp/xsessionrc

I'm using gdm (the "classic" one, not gdm3) as my display manager, and if I change the language in gdm, the Xfce session uses the language chosen in gdm (which I suppose is the expected behavior).

So my questions are:

  1. What's overwriting the value that I'm setting for the LANG variable?
  2. How / where should I set it so that I can enforce a specific locale for Xfce and graphical applications?


UPDATE:

It turns out that adding an export LC_ALL=es_ES.UTF-8 before the export LANG makes the variable value stick and Xfce starts in the chosen language. A couple of things:

  • Why does this work on Lenny without needing to set LC_ALL, but doesn't work on Squeeze?
  • I got the tip about setting LC_ALL from the LXDE documentation page that covers setting it up in Debian. However, the Debian documentation covering this doesn't seem to mention anything about LC_ALL needing to be set. 
UPDATE 2:
  • My system (default) locale is en_US.UTF-8. I've generated es_ES.UTF-8 as an additional locale through dpkg-reconfigure locales.
  • I need to set the alternative locale (es_ES.UTF-8) for specific accounts. The LC_ALL tip that I discovered before (see previous "UPDATE") works, but it has the side effect of translating console applications too (like apt), which is not what I want.
    or Cancel

    2 answers

    1

    rhonda [ Editor ]

    The proper way to do this is choosing the language in gdm indeed. I’m uncertain why this doesn’t please you.

    Said that, if you need to explicitly set LCALL and setting LANG alone doesn’t work, redirect the output of locale to a file. Values that have quotes around them are implicitly set, the lines without the quotes in them are the important ones to look at. Somehow I suspect that LCMESSAGES seems to be set somewhere, and when you set LANG that one won’t pick up that value, but if you set LCALL you override all the settings explicitly and nothing else will be looked at anymore. So try setting LCMESSAGES and see if that solves your issue.

    About your second updated, this makes me really wonder: You managed to get xfce having a spanish interface but no other applications? That’s actually very strange and somewhat unexpected because they should use the same environment. You probably have to unset/reset your locale settings in your shell startups to manage that.

    NN comments
    alex
    -

    Hi rhonda, and thanks for taking the time to reply. I’ve done a few more tests, and found the following. If I put only an export LANG=esES.UTF-8 in the .xsessionrc file, I get this as the locale command output: LCMESSAGES=“esES.UTF-8” (and both Xfce and the rest of the apps display in English). However, if I also add an export LCMESSAGES=esES.UTF-8 to the .xsessionrc file, the locale output shows LCMESSAGES=es_ES.UTF-8, and then everything is displayed in Spanish.

    I mentioned that I was using gdm just to give some more background. If I needed to change the locale just for me, then I guess I could choose the right language in gdm without needing to mess with config files. But I need this for an environment in which not all the users will be logging in through gdm, some of them may be logging in remotely (FreeNX), and that’s why I can’t rely on gdm for setting the right locale. In other words, I need to make sure that each user account gets the right locale, without the end user having to do anything, and the method should work always and idependently of where he or she is logging in from (locally or remotely).

    or Cancel
    0

    gnubyexample [ Editor ]

    The versions for Xfce are 4.4 in Lenny and 4.6 in Squeeze

    As an Xfce user myself, I look forward to Xfce 4.8 (or even 4.10) being the new version in next Debian (Wheezy in 2013). There may be one or two minor adjustments I will make personally as part of accepting that new Xfce version.

    Choosing a desktop used and supported by a smaller community, is my personal choice, and if the implementation requires me to make some small adjustments, then so be it.
    For me I still prefer this, rather than using full Gnome or KDE (both of which probably have large ‘upgrade teams’ and a user taskbar applet for switching Locale).

    The link to Debian documentation you gave is very generic rather than being tailored to a particular desktop (Xfce, Gnome, KDE).
    Because Squeeze was only released 1 month ago, some install experiences will be new.
    However by doing this Q&A you are adding to the body of knowledge, and could make suggestions for inclusion in that Debian documentation.

    One thing that is not clear from your question is whether your default locale is set correctly. Should your default locale for the machine be es_ES.UTF-8?

    Here is what I get if I run /usr/sbin/locale-gen

    ~# locale-gen
    Generating locales (this might take a while)...
    en_GB.UTF-8... done
    en_US.ISO-8859-15... done
    Generation complete.

    Please post the output of locale-gen so that can be part of the understanding of your situation.

    Note: Xfce is a ‘light desktop’ which does not currently aim to include things like bluetooth graphical management in the panel.
    You can request this feature be added to Xfce by joining that community.
    If there are enough requests for it and developer resources available, then it may get some backing.

    NN comments
    alex
    -

    Hi Gary, and thank you for taking the time to write your reply. I’m quite familiar with Xfce, since it has always been my alternative desktop of choice, and my only one since the KDE 4 fiasco in Squeeze. I am aware of its various limitations, but I accept them as a fair trade-off. I’m quite sure that 4.8 represents a big progress for the Xfce project, and it would be awesome if the DDs could backport it in the near term (so we don’t have to wait 2 more years until Wheezy is released as stable). With regard to my question, I’ll post some more details as an update.

    or Cancel

    Your answer

    You need to join Debian to complete this action, click here to do so.