[gtksourceview] Manage i18n on win32 and osx.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtksourceview] Manage i18n on win32 and osx.
- Date: Fri, 18 Dec 2009 20:05:47 +0000 (UTC)
commit 0188ac23db4963dc639683f18cc910727637a297
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Fri Dec 18 21:05:22 2009 +0100
Manage i18n on win32 and osx.
configure.ac | 20 +++++++++++++-
gtksourceview/Makefile.am | 3 +-
gtksourceview/gtksourceview-i18n.c | 52 ++++++++++++++++++++++++++++++++---
gtksourceview/gtksourceview-i18n.h | 9 ++----
4 files changed, 71 insertions(+), 13 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index cdc9c54..0d77ca3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,13 +76,31 @@ AC_ARG_ENABLE(providers,
AM_CONDITIONAL(ENABLE_PROVIDERS, test "x$enable_providers" = "xyes")
+dnl check for native osx
+AC_MSG_CHECKING([for native Mac OS X])
+
+gdk_windowing=`$PKG_CONFIG --variable=target gdk-2.0`
+
+if test "$gdk_windowing" = "quartz"; then
+ os_osx=yes
+else
+ os_osx=no
+fi
+AC_MSG_RESULT([$os_osx])
+AM_CONDITIONAL(OS_OSX, test "$os_osx" = "yes")
+
+if test "$os_osx" = "yes"; then
+ AC_DEFINE([OS_OSX],[1],[Defined if os is Mac OSX])
+
+ PKG_CHECK_MODULES(IGE_MAC, ige-mac-integration)
+fi
+
# i18N stuff
GETTEXT_PACKAGE=gtksourceview-2.0
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Package name for gettext])
AM_GLIB_GNU_GETTEXT
-AM_GLIB_DEFINE_LOCALEDIR(LOCALEDIR)
# test-widget uses this to find lang files and gtksourcebuffer.c
ABS_TOP_SRCDIR=`cd $srcdir && pwd`
diff --git a/gtksourceview/Makefile.am b/gtksourceview/Makefile.am
index f9752aa..16da221 100644
--- a/gtksourceview/Makefile.am
+++ b/gtksourceview/Makefile.am
@@ -10,6 +10,7 @@ INCLUDES = \
-I$(top_srcdir) -I$(srcdir) \
$(DISABLE_DEPRECATED_CFLAGS) \
$(WARN_CFLAGS) \
+ $(IGE_MAC_CFLAGS) \
$(DEP_CFLAGS)
BUILT_SOURCES = \
@@ -93,7 +94,7 @@ nodist_libgtksourceview_2_0_la_SOURCES =\
completion_providers = \
completion-providers/words/libgtksourcecompletionwords.la
-libgtksourceview_2_0_la_LIBADD = $(DEP_LIBS) $(completion_providers)
+libgtksourceview_2_0_la_LIBADD = $(DEP_LIBS) $(IGE_MAC_LIBS) $(completion_providers)
libgtksourceview_2_0_la_LDFLAGS = -no-undefined -export-symbols-regex "^gtk_source_.*"
libgtksourceview_2_0_includedir = $(includedir)/gtksourceview-2.0/gtksourceview
diff --git a/gtksourceview/gtksourceview-i18n.c b/gtksourceview/gtksourceview-i18n.c
index e121663..e4db3eb 100644
--- a/gtksourceview/gtksourceview-i18n.c
+++ b/gtksourceview/gtksourceview-i18n.c
@@ -23,15 +23,51 @@
#include <config.h>
#endif
-#include "gtksourceview-i18n.h"
+#ifdef OS_OSX
+#include <ige-mac-bundle.h>
+#endif
+
#include <string.h>
+#include "gtksourceview-i18n.h"
+
+static gchar *
+get_locale_dir (void)
+{
+ gchar *locale_dir;
+
+#ifdef G_OS_WIN32
+ gchar *win32_dir;
+
+ win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
+
+ locale_dir = g_build_filename (win32_dir, "share", "locale", NULL);
+
+ g_free (win32_dir);
+#elif defined (OS_OSX)
+ IgeMacBundle *bundle = ige_mac_bundle_get_default ();
+
+ if (ige_mac_bundle_get_is_app_bundle (bundle))
+ {
+ locale_dir = g_strdup (ige_mac_bundle_get_localedir (bundle));
+ }
+ else
+ {
+ locale_dir = g_build_filename (DATADIR, "locale", NULL);
+ }
+#else
+ locale_dir = g_build_filename (DATADIR, "locale", NULL);
+#endif
+
+ return locale_dir;
+}
+
/*
* Small hack since we don't have a proper place where
* do gettext initialization.
*/
-char *
-_gtksourceview_gettext (const char *msgid)
+const gchar *
+_gtksourceview_gettext (const gchar *msgid)
{
static gboolean initialized = FALSE;
@@ -40,12 +76,18 @@ _gtksourceview_gettext (const char *msgid)
if (G_UNLIKELY (!initialized))
{
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ gchar *locale_dir;
+
+ locale_dir = get_locale_dir ();
+
+ bindtextdomain (GETTEXT_PACKAGE, locale_dir);
+ g_free (locale_dir);
+
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
initialized = TRUE;
}
- return dgettext (GETTEXT_PACKAGE, msgid);
+ return g_dgettext (GETTEXT_PACKAGE, msgid);
}
/**
diff --git a/gtksourceview/gtksourceview-i18n.h b/gtksourceview/gtksourceview-i18n.h
index c7f269d..ccafb9a 100644
--- a/gtksourceview/gtksourceview-i18n.h
+++ b/gtksourceview/gtksourceview-i18n.h
@@ -19,10 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
- @NOTATION@
- */
-
-/*
* Handles all of the internationalization configuration options.
* Author: Tom Tromey <tromey creche cygnus com>
*/
@@ -42,6 +38,7 @@ G_BEGIN_DECLS
# include <libintl.h>
# undef _
# define _(String) _gtksourceview_gettext (String)
+# undef N_
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
@@ -71,9 +68,9 @@ G_BEGIN_DECLS
# define GD_(Domain,String) (g_strdup (String))
#endif
-char *_gtksourceview_gettext (const char *msgid) G_GNUC_FORMAT(1);
+const gchar *_gtksourceview_gettext (const char *msgid) G_GNUC_FORMAT(1);
/* NOTE: it returns duplicated string */
-char *_gtksourceview_dgettext (const char *domain, const char *msgid) G_GNUC_FORMAT(2);
+gchar *_gtksourceview_dgettext (const char *domain, const char *msgid) G_GNUC_FORMAT(2);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]