[network-manager-applet] build: enable country list translation in mobile broadband wizard (rh #632965)



commit 79e1bddf4e723df78bedc4164f8a4f8576c9e36d
Author: JiÅÃ KlimeÅ <jklimes redhat com>
Date:   Tue Aug 30 14:48:07 2011 +0200

    build: enable country list translation in mobile broadband wizard (rh #632965)
    
    List of countries is taken from /usr/share/zoneinfo/iso3166.tab file.

 configure.ac                     |    2 ++
 m4/translate_countries.m4        |    7 +++++++
 po/POTFILES.in                   |    1 +
 po/Rules-iso3166                 |   11 +++++++++++
 src/utils/nmn-mobile-providers.c |   14 ++++++++------
 5 files changed, 29 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2861c50..ed39e79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,6 +57,8 @@ GETTEXT_PACKAGE=nm-applet
 AC_SUBST(GETTEXT_PACKAGE)
 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
 AM_GLIB_GNU_GETTEXT
+# for translation of country names from /usr/share/zoneinfo/iso3166.tab
+TRANSLATE_COUNTRY_NAMES([po])
 
 dnl
 dnl Make sha1.c happy on big endian systems
diff --git a/m4/translate_countries.m4 b/m4/translate_countries.m4
new file mode 100644
index 0000000..fa1ad2b
--- /dev/null
+++ b/m4/translate_countries.m4
@@ -0,0 +1,7 @@
+AC_DEFUN([TRANSLATE_COUNTRY_NAMES], [
+	AC_CONFIG_COMMANDS([country-names], [
+	if test -f "$1/Rules-iso3166"; then
+		cat "$1/Rules-iso3166" >> po/Makefile.in
+	fi
+	])
+])
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 4afbe21..fcecec6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -15,6 +15,7 @@ src/applet.c
 src/applet.h
 [type: gettext/glade]src/gsm-unlock.ui
 [type: gettext/glade]src/info.ui
+po/iso3166.tab.h
 [type: gettext/glade]src/wired-8021x.ui
 src/connection-editor/ce-page.c
 [type: gettext/glade]src/connection-editor/ce-ip4-routes.ui
diff --git a/po/Rules-iso3166 b/po/Rules-iso3166
new file mode 100644
index 0000000..d2aa1ab
--- /dev/null
+++ b/po/Rules-iso3166
@@ -0,0 +1,11 @@
+# For translation of country names (taken from /usr/share/zoneinfo/iso3166.tab)
+$(top_builddir)/po/iso3166.tab.h: $(datadir)/zoneinfo/iso3166.tab
+	@rm -f $(top_builddir)/po/iso3166.tab.h
+	@cat $(datadir)/zoneinfo/iso3166.tab | grep -v "#" | cut -f 2 | while read country ; do \
+		echo "char *s = N_(\"$${country}\")" >> $(top_builddir)/po/iso3166.tab.h ; \
+	done
+
+mostlyclean-iso3166:
+	rm -f $(top_builddir)/po/iso3166.tab.h
+
+mostlyclean: mostlyclean-iso3166
diff --git a/src/utils/nmn-mobile-providers.c b/src/utils/nmn-mobile-providers.c
index 9120aef..8a244e8 100644
--- a/src/utils/nmn-mobile-providers.c
+++ b/src/utils/nmn-mobile-providers.c
@@ -18,7 +18,7 @@
  * Copyright (C) 2009 Novell, Inc.
  * Author: Tambet Ingo (tambet gmail com).
  *
- * Copyright (C) 2009 - 2010 Red Hat, Inc.
+ * Copyright (C) 2009 - 2011 Red Hat, Inc.
  */
 
 #include "config.h"
@@ -68,17 +68,19 @@ read_country_codes (void)
         case G_IO_STATUS_NORMAL:
             if (buffer->str[0] != '#') {
                 char **pieces;
+                char *country_name;
 
                 pieces = g_strsplit (buffer->str, "\t", 2);
 
                 /* Hack for rh#556292; iso3166.tab is just wrong */
                 pieces[1] = pieces[1] ? g_strchomp (pieces[1]) : NULL;
-                if (pieces[1] && !strcmp (pieces[1], "Britain (UK)")) {
-                    g_free (pieces[1]);
-                    pieces[1] = g_strdup (_("United Kingdom"));
-                }
+                if (pieces[1] && !strcmp (pieces[1], "Britain (UK)"))
+                    country_name = g_strdup (_("United Kingdom"));
+                else
+                    country_name = g_strdup (gettext (pieces[1]));
 
-                g_hash_table_insert (table, pieces[0], pieces[1]);
+                g_hash_table_insert (table, pieces[0], country_name);
+                g_free (pieces[1]);
                 g_free (pieces);
             }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]