summaryrefslogtreecommitdiff
path: root/debian/patches/04_language_handling.patch
blob: f50fdfc40c6573b260d44cb4c4cc212b89bea62f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Description: Adjustments due to handling of languages
Forwarded: not-needed
Author: Gunnar Hjalmarsson <gunnarhj@ubuntu.com>

Index: trunk/liblightdm-gobject/language.c
===================================================================
--- trunk.orig/liblightdm-gobject/language.c
+++ trunk/liblightdm-gobject/language.c
@@ -40,7 +40,7 @@ static GList *languages = NULL;
 static void
 update_languages (void)
 {
-    gchar *command = "locale -a";
+    gchar *command = "/usr/share/language-tools/language-options";
     gchar *stdout_text = NULL, *stderr_text = NULL;
     gint exit_status;
     gboolean result;
@@ -161,15 +161,39 @@ lightdm_get_language (void)
 {
     const gchar *lang;
     GList *link;
+    static const gchar *short_lang = NULL;
+
+    if (short_lang)
+        goto match;
 
     lang = g_getenv ("LANG");
     if (!lang)
         return NULL;
 
+    /* Convert to a short form language code */
+    gchar *command = g_strconcat ("/usr/share/language-tools/language-validate ", lang, NULL);
+    gchar *out;
+    GError *error = NULL;
+    if (g_spawn_command_line_sync (command, &out, NULL, NULL, &error))
+    {
+        short_lang = g_strdup (g_strchomp (out));
+        g_free (out);
+        g_free (command);
+    }
+    else
+    {
+        g_warning ("Failed to run '%s': %s", command, error->message);
+        g_error_free (error);
+        g_free (command);
+        return NULL;
+    }
+
+match:
+
     for (link = lightdm_get_languages (); link; link = link->next)
     {
         LightDMLanguage *language = link->data;
-        if (lightdm_language_matches (language, lang))
+        if (lightdm_language_matches (language, short_lang))
             return language;
     }
 
Index: trunk/tests/scripts/language-env.conf
===================================================================
--- trunk.orig/tests/scripts/language-env.conf
+++ trunk/tests/scripts/language-env.conf
@@ -24,8 +24,8 @@ user-session=default
 #?SESSION-X-0 CONNECT-XSERVER
 
 # Check environment variables
-#?*SESSION-X-0 READ-ENV NAME=LANG
-#?SESSION-X-0 READ-ENV NAME=LANG VALUE=en_AU
+#?*SESSION-X-0 READ-ENV NAME=LANGUAGE
+#?SESSION-X-0 READ-ENV NAME=LANGUAGE VALUE=en_AU
 #?*SESSION-X-0 READ-ENV NAME=GDM_LANG
 #?SESSION-X-0 READ-ENV NAME=GDM_LANG VALUE=en_AU
 
Index: trunk/src/seat.c
===================================================================
--- trunk.orig/src/seat.c
+++ trunk/src/seat.c
@@ -999,7 +999,7 @@ configure_session (Session *session, Ses
     }
     if (language && language[0] != '\0')
     {
-        session_set_env (session, "LANG", language);
+        session_set_env (session, "LANGUAGE", language);
         session_set_env (session, "GDM_LANG", language);
     }
 }