=== modified file 'data/Xsession.in'
--- data/Xsession.in	2010-08-12 13:58:58 +0000
+++ data/Xsession.in	2010-10-26 16:45:10 +0000
@@ -146,11 +146,56 @@
 
 unset XKB_IN_USE
 
-# Overwrite $LANG from /etc/profile (and friends) with the one picked in the
-# greeter
-if [ -n "$GDM_LANG" ]; then
-  LANG="$GDM_LANG"
-  export LANG
+#
+# the language_update() function will be called when the user has
+# changed language from the greeter
+#
+language_update() {
+    # make the first value in the LANGUAGE priority list correspond
+    # with the language selected in the greeter
+    if [ -n "$LANGUAGE" -a $gdm_selected != 'en' ]; then
+        case $LANGUAGE in
+            *:$gdm_selected:*)  LANGUAGE=$( echo $LANGUAGE | \
+                                  sed -r "s/(.+:)($gdm_selected:)/\2\1/" ) ;;
+            *)                  LANGUAGE=$gdm_selected:$LANGUAGE ;;
+        esac
+    else
+        LANGUAGE=$gdm_selected
+    fi
+    export LANGUAGE
+
+    # set LC_MESSAGES for applications that don't recognize LANGUAGE
+    locales=$( locale -a | grep -F .utf8 )
+    if [ "$( echo $locales | grep -F $GDM_LANG )" ]; then
+        LC_MESSAGES=$GDM_LANG
+    else
+        for loc in $locales; do
+            if [ $gdm_selected = ${loc%_*} ]; then
+                LC_MESSAGES=$loc
+                break
+            fi
+        done
+    fi
+    export LC_MESSAGES
+
+    profile_update() {
+        var=$1; value=$2
+        if [ "$( grep "^[^#]*$var=" $HOME/.profile )" ]; then
+            sed -r -i "s/^([^#]*$var=)[^[:space:];]*/\1\"$value\"/" $HOME/.profile
+        else
+            echo "export $var=\"$value\"" >> $HOME/.profile
+        fi
+    }
+    profile_update 'LANGUAGE' $LANGUAGE
+    profile_update 'LC_MESSAGES' $LC_MESSAGES
+}
+
+# new language set in greeter?
+if [ -n "$GDM_LANG" -a $GDMSESSION != 'guest-restricted' ]; then
+    gdm_selected=${GDM_LANG%.*}
+    if [ $gdm_selected != ${LANGUAGE%%:*} ]; then
+        language_update
+    fi
 fi
 
 # run all system xinitrc shell scripts.

