~ubuntu-branches/ubuntu/vivid/gnome-desktop3/vivid-proposed

« back to all changes in this revision

Viewing changes to debian/patches/ubuntu_language.patch

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2013-05-28 09:10:46 UTC
  • mfrom: (1.6.1) (21.1.10 experimental)
  • Revision ID: package-import@ubuntu.com-20130528091046-b0oc28za9l97fgq1
Tags: 3.8.2-0ubuntu1
* New upstream release
* Sync with Debian (LP: #1184812) Remaining changes:
  - debian/patches:
    + 04_compute_average_color.patch: Compute the avergage color in
      gnome-desktop itself, not in unity to fix some races (LP #963140)
    + tweak_color_computation.patch, Patch from Gord, no patch header,
      no bug link.
    + git_revert_draw_background.patch
    + ubuntu_language.patch, Ported relevant bits from g-c-c 
      52_region_language.patch, as required for gnome 3.8 region panel
    + ubuntu_language_list_from_SUPPORTED.patch,
      adds api to get list of available languages from SUPPORTED file.
      To be used by gnome 3.8 region panel language installation.
  - debian/control.in:
    + Don't break gnome-shell << 3.7.90
    + Use source:Version for gnome-desktop3-data Depend
    + Add epoch to gnome-desktop3-data's Breaks/Replaces, as our old
      gnome-desktop source package introduced an epoch. This needs to be
      kept until after 14.04 LTS.
 - Install helper tools into a versioned directory (by overriding
   libexecdir). They could alternatively be installed in a separate package
* Dropped changes:
  - 02_refuse_to_break_GL_compositors.patch:
    + Doesn't appear to be needed any more
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
This patch was taken from gnome-control-center 52_region_language.patch,
 
2
where relevent language code used to live in 3.6
 
3
 
 
4
Description: Adapts the region capplet and the language chooser in the user accounts capplet
 
5
Forwarded: https://bugzilla.gnome.org/695939, https://bugzilla.gnome.org/695940
 
6
Author: Gunnar Hjalmarsson <gunnarhj@ubuntu.com>
 
7
Last-Update: 2013-04-10
 
8
 
 
9
 * Ubuntu isn't shipped with all languages installed and all locales generated.
 
10
   Instead the users install the needed language pack(s), and the corresponding
 
11
   locales are generated.
 
12
 
 
13
 * Locales stored with codeset '.UTF-8' instead of '.utf8'.
 
14
 
 
15
 * The 'common_name' field taken into account when parsing the iso-codes XML files
 
16
   for language names.
 
17
 
 
18
---
 
19
 libgnome-desktop/gnome-languages.c | 75 +++++++++++++++++++++++++++++---------
 
20
 1 file changed, 57 insertions(+), 18 deletions(-)
 
21
 
 
22
diff --git a/libgnome-desktop/gnome-languages.c b/libgnome-desktop/gnome-languages.c
 
23
index 18e3705..eaa6622 100644
 
24
--- a/libgnome-desktop/gnome-languages.c
 
25
+++ b/libgnome-desktop/gnome-languages.c
 
26
@@ -97,6 +97,7 @@ normalize_codeset (const char *codeset)
 
27
         char *q;
 
28
 
 
29
         normalized_codeset = g_strdup (codeset);
 
30
+        return normalized_codeset;
 
31
 
 
32
         if (codeset != NULL) {
 
33
                 for (p = codeset, q = normalized_codeset;
 
34
@@ -242,6 +243,7 @@ construct_language_name (const char *language,
 
35
                          const char *codeset,
 
36
                          const char *modifier)
 
37
 {
 
38
+        const char *adj_codeset;
 
39
         char *name;
 
40
 
 
41
         g_assert (language[0] != 0);
 
42
@@ -249,12 +251,17 @@ construct_language_name (const char *language,
 
43
         g_assert (codeset == NULL || codeset[0] != 0);
 
44
         g_assert (modifier == NULL || modifier[0] != 0);
 
45
 
 
46
+        if (g_strcmp0 (codeset, "utf8") == 0) {
 
47
+                adj_codeset = "UTF-8";
 
48
+        } else
 
49
+                adj_codeset = codeset;
 
50
+
 
51
         name = g_strdup_printf ("%s%s%s%s%s%s%s",
 
52
                                 language,
 
53
                                 territory != NULL? "_" : "",
 
54
                                 territory != NULL? territory : "",
 
55
                                 codeset != NULL? "." : "",
 
56
-                                codeset != NULL? codeset : "",
 
57
+                                codeset != NULL? adj_codeset : "",
 
58
                                 modifier != NULL? "@" : "",
 
59
                                 modifier != NULL? modifier : "");
 
60
 
 
61
@@ -315,7 +322,6 @@ language_name_is_valid (const char *language_name)
 
62
 #else
 
63
         int lc_type_id = LC_MESSAGES;
 
64
 #endif
 
65
-
 
66
         old_locale = g_strdup (setlocale (lc_type_id, NULL));
 
67
         is_valid = setlocale (lc_type_id, language_name) != NULL;
 
68
         setlocale (lc_type_id, old_locale);
 
69
@@ -347,8 +353,7 @@ language_name_get_codeset_details (const char  *language_name,
 
70
 
 
71
         if (is_utf8 != NULL) {
 
72
                 codeset = normalize_codeset (codeset);
 
73
-
 
74
-                *is_utf8 = strcmp (codeset, "utf8") == 0;
 
75
+                *is_utf8 = strcmp (codeset, "UTF-8") == 0;
 
76
                 g_free (codeset);
 
77
         }
 
78
 
 
79
@@ -419,8 +424,7 @@ add_locale (const char *language_name,
 
80
         if (is_utf8) {
 
81
                 name = g_strdup (language_name);
 
82
         } else if (utf8_only) {
 
83
-                name = g_strdup_printf ("%s.utf8", language_name);
 
84
-
 
85
+                name = g_strdup_printf ("%s.UTF-8", language_name);
 
86
                 language_name_get_codeset_details (name, NULL, &is_utf8);
 
87
                 if (!is_utf8) {
 
88
                         g_free (name);
 
89
@@ -631,6 +635,30 @@ collect_locales_from_directory (void)
 
90
         return found_locales;
 
91
 }
 
92
 
 
93
+static gboolean
 
94
+collect_locales_from_ubuntu (void)
 
95
+{
 
96
+        /* Add installed languages */
 
97
+        gboolean found_locales = FALSE;
 
98
+        char *name;
 
99
+        gchar  *avail_languages;
 
100
+        GError *error = NULL;
 
101
+        if (g_spawn_command_line_sync ("/usr/share/language-tools/language-options",
 
102
+                                        &avail_languages, NULL, NULL, &error)) {
 
103
+                name = strtok (avail_languages, "\n");
 
104
+                while (name != NULL) {
 
105
+                        if (add_locale (name, TRUE))
 
106
+                                found_locales = TRUE;
 
107
+                        name = strtok (NULL, "\n");
 
108
+                }
 
109
+                g_free (avail_languages);
 
110
+        } else {
 
111
+                g_warning ("Couldn't get available locales: %s", error->message);
 
112
+                g_error_free (error);
 
113
+        }
 
114
+        return found_locales;
 
115
+}
 
116
+
 
117
 static void
 
118
 count_languages_and_territories (void)
 
119
 {
 
120
@@ -667,23 +695,16 @@ count_languages_and_territories (void)
 
121
 static void
 
122
 collect_locales (void)
 
123
 {
 
124
-        gboolean found_archive_locales = FALSE;
 
125
-        gboolean found_dir_locales = FALSE;
 
126
+        gboolean found_locales;
 
127
         GError *error = NULL;
 
128
 
 
129
         if (gnome_available_locales_map == NULL) {
 
130
                 gnome_available_locales_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) gnome_locale_free);
 
131
         }
 
132
 
 
133
+        found_locales = collect_locales_from_ubuntu ();
 
134
 
 
135
-        if (!collect_locales_from_archive (&found_archive_locales, &error)) {
 
136
-                g_warning ("Failed to load locales from archive: %s", error->message);
 
137
-                g_clear_error (&error);
 
138
-        }
 
139
-
 
140
-        found_dir_locales = collect_locales_from_directory ();
 
141
-
 
142
-        if (!(found_archive_locales || found_dir_locales)) {
 
143
+        if (!found_locales) {
 
144
 #ifndef WITH_INCOMPLETE_LOCALES
 
145
                 g_warning ("Could not read list of available locales from libc, "
 
146
                            "guessing possible locales from available translations, "
 
147
@@ -877,6 +898,7 @@ languages_parse_start_tag (GMarkupParseContext      *ctx,
 
148
         const char *ccode_longT;
 
149
         const char *ccode;
 
150
         const char *ccode_id;
 
151
+        const char *lang_common_name;
 
152
         const char *lang_name;
 
153
 
 
154
         if (! (g_str_equal (element_name, "iso_639_entry") || g_str_equal (element_name, "iso_639_3_entry"))
 
155
@@ -888,6 +910,7 @@ languages_parse_start_tag (GMarkupParseContext      *ctx,
 
156
         ccode_longB = NULL;
 
157
         ccode_longT = NULL;
 
158
         ccode_id = NULL;
 
159
+        lang_common_name = NULL;
 
160
         lang_name = NULL;
 
161
 
 
162
         while (*attr_names && *attr_values) {
 
163
@@ -924,6 +947,11 @@ languages_parse_start_tag (GMarkupParseContext      *ctx,
 
164
                                 }
 
165
                                 ccode_id = *attr_values;
 
166
                         }
 
167
+                } else if (g_str_equal (*attr_names, "common_name")) {
 
168
+                        /* skip if empty */
 
169
+                        if (**attr_values) {
 
170
+                                lang_common_name = *attr_values;
 
171
+                        }
 
172
                 } else if (g_str_equal (*attr_names, "name")) {
 
173
                         lang_name = *attr_values;
 
174
                 }
 
175
@@ -932,6 +960,10 @@ languages_parse_start_tag (GMarkupParseContext      *ctx,
 
176
                 ++attr_values;
 
177
         }
 
178
 
 
179
+        if (lang_common_name != NULL) {
 
180
+                lang_name = lang_common_name;
 
181
+        }
 
182
+
 
183
         if (lang_name == NULL) {
 
184
                 return;
 
185
         }
 
186
@@ -1174,6 +1206,7 @@ gnome_get_language_from_locale (const char *locale,
 
187
         char *langinfo_codeset;
 
188
         char *translated_language;
 
189
         char *translated_territory;
 
190
+        char *modifier;
 
191
         gboolean is_utf8 = TRUE;
 
192
 
 
193
         g_return_val_if_fail (locale != NULL, NULL);
 
194
@@ -1191,12 +1224,13 @@ gnome_get_language_from_locale (const char *locale,
 
195
         language_code = NULL;
 
196
         territory_code = NULL;
 
197
         codeset_code = NULL;
 
198
+        modifier = NULL;
 
199
 
 
200
         gnome_parse_locale (locale,
 
201
                             &language_code,
 
202
                             &territory_code,
 
203
                             &codeset_code,
 
204
-                            NULL);
 
205
+                            &modifier);
 
206
 
 
207
         if (language_code == NULL) {
 
208
                 goto out;
 
209
@@ -1222,7 +1256,7 @@ gnome_get_language_from_locale (const char *locale,
 
210
                                         translated_territory);
 
211
         }
 
212
 
 
213
-        language_name_get_codeset_details (locale, &langinfo_codeset, &is_utf8);
 
214
+        //language_name_get_codeset_details (locale, &langinfo_codeset, &is_utf8);
 
215
 
 
216
         if (codeset_code == NULL && langinfo_codeset != NULL) {
 
217
                 codeset_code = g_strdup (langinfo_codeset);
 
218
@@ -1234,6 +1268,10 @@ gnome_get_language_from_locale (const char *locale,
 
219
                                         codeset_code);
 
220
         }
 
221
 
 
222
+        if (modifier != NULL) {
 
223
+                g_string_append_printf (full_language, " - %s", modifier);
 
224
+        }
 
225
+
 
226
  out:
 
227
         g_free (language_code);
 
228
         g_free (territory_code);
 
229
@@ -1241,6 +1279,7 @@ gnome_get_language_from_locale (const char *locale,
 
230
         g_free (langinfo_codeset);
 
231
         g_free (translated_language);
 
232
         g_free (translated_territory);
 
233
+        g_free (modifier);
 
234
 
 
235
         if (full_language->len == 0) {
 
236
                 g_string_free (full_language, TRUE);
 
237
-- 
 
238
1.8.1.2
 
239
 
 
240
 
 
241