[frogr] Make frogr to find locale files regardless of the platform



commit d677eb9d9bfa9c2f2b5fe0b3f9ab906475086735
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Thu May 19 02:48:27 2011 +0200

    Make frogr to find locale files regardless of the platform

 configure.ac     |    2 +-
 src/frogr-util.c |   20 ++++++++++++++++++++
 src/frogr-util.h |    2 ++
 src/main.c       |    3 ++-
 4 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f1ebeab..153e2c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -120,7 +120,7 @@ FROGR_CFLAGS="$FROGR_CFLAGS $GTK_CFLAGS"
 FROGR_LIBS="$FROGR_LIBS $GTK_LIBS"
 
 # Translations
-FROGR_LOCALE_DIR='$prefix/${DATADIRNAME}/locale'
+FROGR_LOCALE_DIR='${localedir}'
 AM_GLIB_DEFINE_LOCALEDIR([FROGR_LOCALE_DIR])
 AM_GLIB_GNU_GETTEXT
 
diff --git a/src/frogr-util.c b/src/frogr-util.c
index d45e5ab..b658092 100644
--- a/src/frogr-util.c
+++ b/src/frogr-util.c
@@ -82,6 +82,26 @@ frogr_util_get_icons_dir (void)
   return (const gchar *) icons_dir;
 }
 
+const gchar *
+frogr_util_get_locale_dir (void)
+{
+  static const gchar *locale_dir = NULL;
+  if (!locale_dir)
+    {
+#ifndef MAC_INTEGRATION
+      /* If not in MacOSX, we trust the defined variable better */
+      locale_dir = g_strdup (FROGR_LOCALE_DIR);
+#endif
+
+      /* Fallback for MacOSX and cases where FROGR_LOCALE_DIR was not
+	 defined yet because of any reason */
+      if (!locale_dir)
+	locale_dir = g_strdup_printf ("%s/locale", _get_data_dir ());
+    }
+
+  return (const gchar *) locale_dir;
+}
+
 void
 frogr_util_open_url_in_browser (const gchar *url)
 {
diff --git a/src/frogr-util.h b/src/frogr-util.h
index 9430d04..42fd8b5 100644
--- a/src/frogr-util.h
+++ b/src/frogr-util.h
@@ -29,6 +29,8 @@ const gchar *frogr_util_get_app_data_dir (void);
 
 const gchar *frogr_util_get_icons_dir (void);
 
+const gchar *frogr_util_get_locale_dir (void);
+
 void frogr_util_open_url_in_browser (const gchar *url);
 
 void frogr_util_show_info_dialog (GtkWindow *parent, const gchar *message);
diff --git a/src/main.c b/src/main.c
index 2b48480..411a907 100644
--- a/src/main.c
+++ b/src/main.c
@@ -23,6 +23,7 @@
 #include "frogr-controller.h"
 
 #include "frogr-global-defs.h"
+#include "frogr-util.h"
 
 #include <config.h>
 #include <glib/gi18n.h>
@@ -96,7 +97,7 @@ main (int argc, char **argv)
 #endif
 
   /* Translation domain */
-  bindtextdomain (GETTEXT_PACKAGE, FROGR_LOCALE_DIR);
+  bindtextdomain (GETTEXT_PACKAGE, frogr_util_get_locale_dir ());
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
   textdomain (GETTEXT_PACKAGE);
 



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