summaryrefslogtreecommitdiffstats
path: root/debian/patches/install-locale-langpack.patch
blob: ae96bab1fc460e2f8723c8317a085e8fe56cf80b (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
From 31e9c5eaec14e18251db1fb7e6e44add22e56526 Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@ubuntu.com>
Date: Mon, 13 Jan 2014 12:13:07 +0000
Subject: Prefer translations from Ubuntu language packs if available

Bug-Ubuntu: https://bugs.launchpad.net/bugs/537998
Forwarded: not-needed
Last-Update: 2013-12-25

Patch-Name: install-locale-langpack.patch
---
 util/grub-install-common.c | 37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)

diff --git a/util/grub-install-common.c b/util/grub-install-common.c
index 4e212e690..e53730485 100644
--- a/util/grub-install-common.c
+++ b/util/grub-install-common.c
@@ -774,17 +774,25 @@ get_localedir (void)
 }
 
 static void
-copy_locales (const char *dstd)
+copy_locales (const char *dstd, int langpack)
 {
   grub_util_fd_dir_t d;
   grub_util_fd_dirent_t de;
   const char *locale_dir = get_localedir ();
+  char *dir;
 
-  d = grub_util_fd_opendir (locale_dir);
+  if (langpack)
+    dir = xasprintf ("%s-langpack", locale_dir);
+  else
+    dir = xstrdup (locale_dir);
+
+  d = grub_util_fd_opendir (dir);
   if (!d)
     {
-      grub_util_warn (_("cannot open directory `%s': %s"),
-		      locale_dir, grub_util_fd_strerror ());
+      if (!langpack)
+	grub_util_warn (_("cannot open directory `%s': %s"),
+			dir, grub_util_fd_strerror ());
+      free (dir);
       return;
     }
 
@@ -801,14 +809,14 @@ copy_locales (const char *dstd)
       if (ext && (grub_strcmp (ext, ".mo") == 0
 		  || grub_strcmp (ext, ".gmo") == 0))
 	{
-	  srcf = grub_util_path_concat (2, locale_dir, de->d_name);
+	  srcf = grub_util_path_concat (2, dir, de->d_name);
 	  dstf = grub_util_path_concat (2, dstd, de->d_name);
 	  ext = grub_strrchr (dstf, '.');
 	  grub_strcpy (ext, ".mo");
 	}
       else
 	{
-	  srcf = grub_util_path_concat_ext (4, locale_dir, de->d_name,
+	  srcf = grub_util_path_concat_ext (4, dir, de->d_name,
 					    "LC_MESSAGES", PACKAGE, ".mo");
 	  dstf = grub_util_path_concat_ext (2, dstd, de->d_name, ".mo");
 	}
@@ -817,6 +825,7 @@ copy_locales (const char *dstd)
       free (dstf);
     }
   grub_util_fd_closedir (d);
+  free (dir);
 }
 #endif
 
@@ -835,13 +844,15 @@ grub_install_copy_nls(const char *src __attribute__ ((unused)),
     {
       char *srcd = grub_util_path_concat (2, src, "po");
       copy_by_ext (srcd, dst_locale, ".mo", 0);
-      copy_locales (dst_locale);
+      copy_locales (dst_locale, 0);
+      copy_locales (dst_locale, 1);
       free (srcd);
     }
   else
     {
       size_t i;
       const char *locale_dir = get_localedir ();
+      char *locale_langpack_dir = xasprintf ("%s-langpack", locale_dir);
 
       for (i = 0; i < install_locales.n_entries; i++)
       {
@@ -858,6 +869,16 @@ grub_install_copy_nls(const char *src __attribute__ ((unused)),
             continue;
           }
         free (srcf);
+        srcf = grub_util_path_concat_ext (4, locale_langpack_dir,
+                                          install_locales.entries[i],
+                                          "LC_MESSAGES", PACKAGE, ".mo");
+        if (grub_install_compress_file (srcf, dstf, 0))
+          {
+            free (srcf);
+            free (dstf);
+            continue;
+          }
+        free (srcf);
         srcf = grub_util_path_concat_ext (4, locale_dir,
                                           install_locales.entries[i],
                                           "LC_MESSAGES", PACKAGE, ".mo");
@@ -867,6 +888,8 @@ grub_install_copy_nls(const char *src __attribute__ ((unused)),
         free (srcf);
         free (dstf);
       }
+
+      free (locale_langpack_dir);
     }
   free (dst_locale);
 #endif