Language selection -- acceptable solution
Jaap Winius
jwinius at umrk.nl
Tue Dec 18 00:07:10 CET 2012
Quoting Lorenzo Sutton <lorenzofsutton at gmail.com>:
> ...
> At this point when at the slim logion you press F1 it should cycle
> the entries in sessions including your newly created startxfce4-nl
> (or whatever you called it), and starting that the locale settings
> should be for NL_nl.
Thank you very much, Lorenzo!
Following your instructions, the only thing I changed initially was to
add some export statements in /usr/bin/startxfce4-nl like this:
export LANG="nl_NL.utf8"
export LANGUAGE="nl_NL.utf8"
export LC_CTYPE="nl_NL.UTF-8"
After that it worked as you described, although this solution does
have one serious disadvantage: since the default language is still
English (which I do not intend to change) users who want Dutch are
forced to change their session language every time they log in. This
is unlike gdm, where it's only necessary to select a language once if
you make it your default.
However, your idea looked so promising that I decided not to abandon
it, but make some improvements to it instead. First, I added the
following code to the beginning of /usr/bin/startxfce4 itself (not to
a copy with a different name):
== BEGIN ============================================
WD=`/bin/pwd`
FILE="$WD/.dmrc"
if [ $0 == "/usr/bin/Nederlands" ]
then
export LANG="nl_NL.utf8"
export LANGUAGE="nl_NL.utf8"
export LC_CTYPE="nl_NL.UTF-8"
/bin/echo "[Desktop]" > $FILE
/bin/echo "Session=default" >> $FILE
/bin/echo "Language=nl_NL.UTF-8" >> $FILE
elif [ $0 == "/usr/bin/English" ]
then
export LANG="en_GB.utf8"
export LANGUAGE="en_GB.utf8"
export LC_CTYPE="en_GB.UTF-8"
/bin/echo "[Desktop]" > $FILE
/bin/echo "Session=default" >> $FILE
/bin/echo "Language=en_GB.UTF-8" >> $FILE
else
if [ -f $FILE ]
then
LNG=`/bin/grep Language $FILE`
if [[ $LNG =~ "en_GB" ]]
then
export LANG="en_GB.utf8"
export LANGUAGE="en_GB.utf8"
export LC_CTYPE="en_GB.UTF-8"
elif [[ $LNG =~ "nl_NL" ]]
then
export LANG="nl_NL.utf8"
export LANGUAGE="nl_NL.utf8"
export LC_CTYPE="nl_NL.UTF-8"
fi
else
export LANG="nl_NL.utf8"
export LANGUAGE="nl_NL.utf8"
export LC_CTYPE="nl_NL.UTF-8"
/bin/echo "[Desktop]" > $FILE
/bin/echo "Session=default" >> $FILE
/bin/echo "Language=nl_NL.UTF-8" >> $FILE
fi
fi
== END ==============================================
More improvements are possible, but this basically does the trick.
Next, I created two aliases:
~# ln -s /usr/bin/startxfce4 /usr/bin/English
~# ln -s /usr/bin/startxfce4 /usr/bin/Nederlands
Last, I modified the sessions statement in /etc/slim.conf so that it
now reads:
sessions English,Nederlands
The code in startxfce4 effectively sets the default Xfce session to
Dutch if there is no ~/.dmrc file that contains a reference to one of
the two supported languages. Toggling F1 allows users to select either
English or Dutch again (Nederlands), after which a ~/.dmrc file is
created and set to that language.
Note that the language setting is saved in the ~/.dmrc file every time
F1 is used to select a language. If ~/.dmrc did not exist previously,
it is always created and set with either the selected language or
default language. This has nothing to do with the default language for
the OS, which is still set to 'none' (or 'C'), i.e. English.
Compared to gmd on Debian squeeze, the only disadvantage of this
solution (besides the fact that it's a hack) is that when English is
selected and an attempt is made to log in, but a wrong password is
given, the selected language (session) reverts to the default when the
greeter is reset for the next login attempt. This is not an issue with
gdm, which unlike slim stays with the selected language, but it seems
a small price to pay for the advantage of no longer having to bother
with a package that is not part of wheezy.
Cheers,
Jaap
More information about the Xfce
mailing list