core,ui,build: Make i18n system actually work
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Tue, 28 Sep 2010 15:05:58 +0000 (18:05 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Tue, 28 Sep 2010 15:09:26 +0000 (18:09 +0300)
Based on a patch from Jonh Wendell <jwendell@gnome.org>.

src/rygel/Makefile.am
src/rygel/rygel-build-config.vapi
src/rygel/rygel-main.vala
src/ui/Makefile.am
src/ui/rygel-preferences-dialog.vala

index a6f6321..49a2712 100644 (file)
@@ -25,7 +25,8 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
            -DDATA_DIR='"$(shareddir)"' -DSYS_CONFIG_DIR='"$(sysconfdir)"'\
            -DPLUGIN_DIR='"$(plugindir)"' -DDESKTOP_DIR='"$(desktopdir)"'\
            -DSMALL_ICON_DIR='"$(smallicondir)"' \
-           -DBIG_ICON_DIR='"$(bigicondir)"' -include config.h
+           -DBIG_ICON_DIR='"$(bigicondir)"' -include config.h \
+           -DLOCALEDIR=\""$(datadir)/locale"\"
 
 librygelincdir = $(includedir)/rygel-1.0
 
index c0bf3f9..9b331a0 100644 (file)
@@ -51,4 +51,10 @@ public class Rygel.BuildConfig {
 
     [CCode (cname = "PACKAGE_STRING")]
     public static const string PACKAGE_STRING;
+
+    [CCode (cname = "GETTEXT_PACKAGE")]
+    public static const string GETTEXT_PACKAGE;
+
+    [CCode (cname = "LOCALEDIR")]
+    public static const string LOCALEDIR;
 }
index 8a983e7..772ffa4 100644 (file)
@@ -212,6 +212,12 @@ public class Rygel.Main : Object {
 
         var original_args = args;
 
+        Intl.setlocale (LocaleCategory.ALL, "");
+        Intl.bindtextdomain (BuildConfig.GETTEXT_PACKAGE,
+                             BuildConfig.LOCALEDIR);
+        Intl.bind_textdomain_codeset (BuildConfig.GETTEXT_PACKAGE, "UTF-8");
+        Intl.textdomain (BuildConfig.GETTEXT_PACKAGE);
+
         try {
             // Parse commandline options
             CmdlineConfig.parse_args (ref args);
index c339929..8500acf 100644 (file)
@@ -18,7 +18,8 @@ AM_CFLAGS = $(LIBGUPNP_CFLAGS) \
            $(LIBSOUP_CFLAGS) \
            $(LIBDBUS_GLIB_CFLAGS) \
            -I$(top_srcdir) -I$(rygeldir) -DDATA_DIR='"$(shareddir)"' \
-           -DSMALL_ICON_DIR='"$(icondir)"' -include config.h
+           -DSMALL_ICON_DIR='"$(icondir)"' -include config.h \
+           -DLOCALEDIR=\""$(datadir)/locale"\"
 
 bin_PROGRAMS = rygel-preferences
 
index 4e88cae..b94a707 100644 (file)
@@ -62,6 +62,12 @@ public class Rygel.PreferencesDialog : GLib.Object {
     }
 
     public static int main (string[] args) {
+        Intl.setlocale (LocaleCategory.ALL, "");
+        Intl.bindtextdomain (BuildConfig.GETTEXT_PACKAGE,
+                             BuildConfig.LOCALEDIR);
+        Intl.bind_textdomain_codeset (BuildConfig.GETTEXT_PACKAGE, "UTF-8");
+        Intl.textdomain (BuildConfig.GETTEXT_PACKAGE);
+
         Gtk.init (ref args);
 
         try {