manpage: improve locale setup in example .xsession (Thanks Harald König)

Harald mentioned he was surprised about the locales we recommend in the
.xsession example, so I’ve re-investigated.

Here is the test program I have used:

    #include <stdio.h>
    #include <locale.h>

    int main() {
        /* SUSv2 setlocale(3) says:
         * Internationalised programs must call setlocale() to initiate
         * a specific language operation. This can be done by calling
         * setlocale() as follows: */
        setlocale(LC_ALL, "");

        printf("LC_NUMERIC is %s\n", setlocale(LC_NUMERIC, NULL));
    }

Then, I have unset LANG and LC_*:

    midna /tmp $ env | grep LANG
    midna /tmp $ env | grep LC
    midna /tmp $

Now, observe that LC_ALL overwrites all specific LC variables:

    midna /tmp $ LC_ALL=de_DE.UTF-8 LC_NUMERIC=en_DK.UTF-8 ./localetest
    LC_NUMERIC is de_DE.UTF-8

However, LANG does not:

    midna /tmp $ LANG=de_DE.UTF-8 ./localetest
    LC_NUMERIC is de_DE.UTF-8
    midna /tmp $ LANG=de_DE.UTF-8 LC_NUMERIC=en_DK.UTF-8 ./localetest
    LC_NUMERIC is en_DK.UTF-8

This is consistent with what perldoc perllocale says:
http://perldoc.perl.org/perllocale.html#ENVIRONMENT
This commit is contained in:
Michael Stapelberg 2012-08-27 15:07:18 +02:00
parent c8cfc77b0a
commit 67999269fd
1 changed files with 8 additions and 12 deletions

View File

@ -262,19 +262,15 @@ xset -b
# Enable zapping (C-A-<Bksp> kills X) # Enable zapping (C-A-<Bksp> kills X)
setxkbmap -option terminate:ctrl_alt_bksp setxkbmap -option terminate:ctrl_alt_bksp
# Enforce correct locales from the beginning # Enforce correct locales from the beginning:
unset LC_COLLATE # LC_ALL is unset since it overwrites everything
export LC_CTYPE=de_DE.UTF-8 # LANG=de_DE.UTF-8 is used, except for:
export LC_TIME=de_DE.UTF-8 # LC_MESSAGES=C never translates program output
export LC_NUMERIC=de_DE.UTF-8 # LC_TIME=en_DK leads to yyyy-mm-dd hh:mm date/time output
export LC_MONETARY=de_DE.UTF-8 unset LC_ALL
export LANG=de_DE.UTF-8
export LC_MESSAGES=C export LC_MESSAGES=C
export LC_PAPER=de_DE.UTF-8 export LC_TIME=en_DK.UTF-8
export LC_NAME=de_DE.UTF-8
export LC_ADDRESS=de_DE.UTF-8
export LC_TELEPHONE=de_DE.UTF-8
export LC_MEASUREMENT=de_DE.UTF-8
export LC_IDENTIFICATION=de_DE.UTF-8
# Use XToolkit in java applications # Use XToolkit in java applications
export AWT_TOOLKIT=XToolkit export AWT_TOOLKIT=XToolkit