--- gdm-2.17.4/daemon/gdm.h.orig	2007-01-11 15:19:28.435011000 +0900
+++ gdm-2.17.4/daemon/gdm.h	2007-01-12 15:20:32.927109000 +0900
@@ -100,6 +100,7 @@ enum {
 #define GDM_LANG       '&'
 #define GDM_SSESS      'C'
 #define GDM_SLANG      'R'
+#define GDM_SETLANG    'L'
 #define GDM_RESET      'A'
 #define GDM_QUIT       'P'
 /* Well these aren't as nice as above, oh well */
@@ -129,6 +130,7 @@ enum {
 #define GDM_INTERRUPT_THEME       'H'
 #define GDM_INTERRUPT_CUSTOM_CMD  'M'
 #define GDM_INTERRUPT_CANCEL      'X'
+#define GDM_INTERRUPT_SELECT_LANG 'O'
 
 /* List delimiter for config file lists */
 #define GDM_DELIMITER_MODULES ":"
--- gdm-2.17.4/daemon/misc.c.orig	2007-01-11 15:35:43.139943000 +0900
+++ gdm-2.17.4/daemon/misc.c	2007-01-12 17:24:04.751480000 +0900
@@ -2183,6 +2183,17 @@ gdm_reset_locale (void)
     gsize i18n_file_length, i;
     GString *line;
     const gchar *p, *q;
+    gchar *gdmlang = g_getenv ("GDM_LANG");
+
+    if (gdmlang)
+      {
+	g_setenv ("LANG", gdmlang, TRUE);
+	g_unsetenv ("LC_ALL");
+	g_unsetenv ("LC_MESSAGES");
+	setlocale (LC_ALL, "");
+	setlocale (LC_MESSAGES, "");
+	return;
+      }
 
     i18n_file_contents = NULL;
     line = NULL; 
--- gdm-2.17.4/daemon/slave.c.orig	2007-01-11 15:19:35.143520000 +0900
+++ gdm-2.17.4/daemon/slave.c	2007-01-12 17:55:37.828371000 +0900
@@ -214,6 +214,7 @@ enum {
 	JMP_SESSION_STOP_AND_QUIT = 1,
 	JMP_JUST_QUIT_QUICKLY = 2
 };
+#define DEFAULT_LANGUAGE "Default"
 #define SIGNAL_EXIT_WITH_JMP(d,how) \
    {											\
 	if ((d)->slavepid == getpid () && return_to_slave_start_jmp) {			\
@@ -2455,6 +2456,7 @@ gdm_slave_greeter (void)
     char *defaultpath;
     char *gdmuser;
     char *moduleslist;
+    const char *gdmlang;
     
     gdm_debug ("gdm_slave_greeter: Running greeter on %s", d->name);
     
@@ -2712,6 +2714,9 @@ gdm_slave_greeter (void)
 	gdm_debug ("gdm_slave_greeter: Greeter on pid %d", (int)pid);
 
 	gdm_slave_send_num (GDM_SOP_GREETPID, d->greetpid);
+	gdmlang = g_getenv ("GDM_LANG");
+	if (gdmlang)
+	  gdm_slave_greeter_ctl_no_ret (GDM_SETLANG, gdmlang);
 
 	run_pictures (); /* Append pictures to greeter if browsing is on */
 
@@ -4190,7 +4195,6 @@ gdm_slave_session_start (void)
     }
 
     g_free (usrsess);
-    g_free (usrlang);
 
     gdm_debug ("Initial setting: session: '%s' language: '%s'\n",
 	       session, ve_sure_string (language));
@@ -4368,6 +4372,17 @@ gdm_slave_session_start (void)
 	gdm_assert_not_reached ();
 	
     default:
+	if (!savelang && language && strcmp (usrlang, language)) {
+		if (gdm_system_locale) {
+			g_setenv ("LANG", gdm_system_locale, TRUE);
+			setlocale (LC_ALL, "");
+			g_unsetenv ("GDM_LANG");
+			/* for "GDM_LANG" */
+			gdm_clearenv_no_lang ();
+			gdm_saveenv ();
+		}
+		gdm_slave_greeter_ctl_no_ret (GDM_SETLANG, DEFAULT_LANGUAGE);
+	}
 	break;
     }
     
@@ -4391,6 +4406,7 @@ gdm_slave_session_start (void)
     g_free (session);
     g_free (save_session);
     g_free (language);
+    g_free (usrlang);
     g_free (gnome_session);
 
     gdm_slave_send_num (GDM_SOP_SESSPID, pid);
@@ -5101,6 +5117,24 @@ check_for_interruption (const char *msg)
 				d->theme_name = g_strdup (&msg[2]);
 			gdm_slave_send_string (GDM_SOP_CHOSEN_THEME, &msg[2]);
 			return TRUE;
+		case GDM_INTERRUPT_SELECT_LANG:
+			if (msg + 2) {
+				gchar *locale = (gchar*)(msg + 2);
+
+				gdm_clearenv ();
+				if (!strcmp (locale, DEFAULT_LANGUAGE))
+					locale = gdm_system_locale;
+				g_setenv ("GDM_LANG", locale, TRUE);
+				g_setenv ("LANG", locale, TRUE);
+				g_unsetenv ("LC_ALL");
+				g_unsetenv ("LC_MESSAGES");
+				setlocale (LC_ALL, "");
+				setlocale (LC_MESSAGES, "");
+				gdm_saveenv ();
+
+				do_restart_greeter = TRUE;
+			}
+			break;
 		default:
 			break;
 		}
--- gdm-2.17.4/gui/gdmlogin.c.orig	2007-01-11 15:19:40.266947000 +0900
+++ gdm-2.17.4/gui/gdmlogin.c	2007-01-12 15:20:32.937247000 +0900
@@ -123,7 +123,7 @@ static GList *users = NULL;
 static GList *users_string = NULL;
 static gint size_of_users = 0;
 
-static const gchar *curlang = NULL;
+static gchar *curlang = NULL;
 static gchar *curuser = NULL;
 static gchar *session = NULL;
 static gchar *language = NULL;
@@ -1086,7 +1086,8 @@ gdm_login_language_handler (GtkWidget *w
     if (!widget)
 	return;
 
-    curlang = g_object_get_data (G_OBJECT (widget), "Language");
+    g_free (curlang);
+    curlang = g_strdup (g_object_get_data (G_OBJECT (widget), "Language"));
     name = gdm_lang_name (curlang,
 			  FALSE /* never_encoding */,
 			  TRUE /* no_group */,
@@ -1098,6 +1099,14 @@ gdm_login_language_handler (GtkWidget *w
     g_free (s);
 
     login_window_resize (FALSE /* force */);
+
+    if (strcmp (curlang, LAST_LANGUAGE)) {
+	     printf ("%c%c%c%s\n", STX,
+	                           BEL,
+	                           GDM_INTERRUPT_SELECT_LANG,
+	                           curlang);
+	     fflush (stdout);
+    }
 }
 
 
@@ -1125,7 +1134,8 @@ gdm_login_language_menu_new (void)
 
     menu = gtk_menu_new ();
 
-    curlang = LAST_LANGUAGE;
+    g_free (curlang);
+    curlang = g_strdup (LAST_LANGUAGE);
 
     item = gtk_radio_menu_item_new_with_mnemonic (NULL, _("_Last"));
     languages = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item));
@@ -1792,6 +1802,16 @@ process_operation (guchar       op_code,
 
 	break;
 
+    case GDM_SETLANG:
+	if (args) {
+	    g_free (curlang);
+	    curlang = g_strdup ((char*)args);
+	}
+	printf ("%c\n", STX);
+	fflush (stdout);
+
+	break;
+
     case GDM_RESET:
 	if (gdm_config_get_bool (GDM_KEY_QUIVER) &&
 	    login->window != NULL &&
--- gdm-2.17.4/gui/greeter/greeter.c.orig	2007-01-11 15:19:45.833166000 +0900
+++ gdm-2.17.4/gui/greeter/greeter.c	2007-01-12 15:20:32.944932000 +0900
@@ -374,6 +374,14 @@ process_operation (guchar       op_code,
 
 	break;
 
+    case GDM_SETLANG:
+	if (args)
+	    greeter_language_set ((char*)args);
+	printf ("%c\n", STX);
+	fflush (stdout);
+
+	break;
+
     case GDM_RESET:
 	/* fall thru to reset */
 
--- gdm-2.17.4/gui/greeter/greeter_action_language.c.orig	2007-01-11 15:19:50.921571000 +0900
+++ gdm-2.17.4/gui/greeter/greeter_action_language.c	2007-01-12 15:20:32.947207000 +0900
@@ -375,7 +375,17 @@ greeter_language_handler (GreeterItemInf
     {
     case GTK_RESPONSE_OK:
       if (dialog_selected_language)
-        greeter_language_set ((char *) dialog_selected_language);
+        {
+          greeter_language_set ((char *) dialog_selected_language);
+          if (strcmp (dialog_selected_language, LAST_LANGUAGE))
+            {
+              printf ("%c%c%c%s\n", STX,
+                                    BEL,
+                                    GDM_INTERRUPT_SELECT_LANG,
+                                    dialog_selected_language);
+              fflush (stdout);
+            }
+        }
       break;
     case GTK_RESPONSE_CANCEL:
     default:
