[gimp/osx-build: 38/46] OS X build: use the help locale from the system's preferences
- From: Sven Claussner <sclaussner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/osx-build: 38/46] OS X build: use the help locale from the system's preferences
- Date: Mon, 30 Jun 2014 19:32:22 +0000 (UTC)
commit 7c28f64511a4fc3d33fcf9d50583feb4f811f80c
Author: Simone Karin Lehmann <simone lisanet de>
Date: Wed Jun 4 19:16:13 2014 +0200
OS X build: use the help locale from the system's preferences
Adaptions by Sven Claussner:
- Only use this language if the user chose language="System Language" in
Preferences/Interface.
- Add some code comments.
app/widgets/Makefile.am | 19 +++++---
app/widgets/gimphelp.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 115 insertions(+), 8 deletions(-)
---
diff --git a/app/widgets/Makefile.am b/app/widgets/Makefile.am
index 55dacc5..05d4164 100644
--- a/app/widgets/Makefile.am
+++ b/app/widgets/Makefile.am
@@ -1,18 +1,23 @@
## Process this file with automake to produce Makefile.in
+if PLATFORM_OSX
+xobjective_c = "-xobjective-c"
+endif
+
AM_CPPFLAGS = \
-DISO_CODES_LOCATION=\"$(ISO_CODES_LOCATION)\" \
-DISO_CODES_LOCALEDIR=\"$(ISO_CODES_LOCALEDIR)\" \
-DG_LOG_DOMAIN=\"Gimp-Widgets\"
INCLUDES = \
- -I$(top_builddir) \
- -I$(top_srcdir) \
+ -I$(top_builddir) \
+ -I$(top_srcdir) \
-I$(top_builddir)/app \
- -I$(top_srcdir)/app \
- $(GEGL_CFLAGS) \
- $(GTK_CFLAGS) \
- -I$(includedir)
+ -I$(top_srcdir)/app \
+ $(GEGL_CFLAGS) \
+ $(GTK_CFLAGS) \
+ -I$(includedir) \
+ $(xobjective_c)
noinst_LIBRARIES = libappwidgets.a
@@ -434,4 +439,4 @@ widgets-enums.c: $(srcdir)/widgets-enums.h $(GIMP_MKENUMS)
--dtail " { 0, NULL, NULL }\n };\n\n static GType type = 0;\n\n if (G_UNLIKELY (!
type))\n {\n type = g_ type@_register_static (\"@EnumName \", values);\n
gimp_type_set_translation_context (type, \"@enumnick \");\n gimp_ type@_set_value_descriptions (type,
descs);\n }\n\n return type;\n}\n" \
$(srcdir)/widgets-enums.h > xgen-wec \
&& cp xgen-wec $(@F) \
- && rm -f xgen-wec
+ && rm -f xgen-wec
\ No newline at end of file
diff --git a/app/widgets/gimphelp.c b/app/widgets/gimphelp.c
index e817ad9..a995706 100644
--- a/app/widgets/gimphelp.c
+++ b/app/widgets/gimphelp.c
@@ -23,6 +23,10 @@
#include <string.h>
+#ifdef PLATFORM_OSX
+#import <Foundation/Foundation.h>
+#endif
+
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
@@ -561,15 +565,113 @@ gimp_help_get_default_domain_uri (Gimp *gimp)
return uri;
}
+/**
+ * gimp_help_get_locales:
+ *
+ * @gimp: the GIMP instance with the configuration to read from
+ *
+ * Returns: a colon (:) separated list of language identifiers in descending
+ * order of priority. The function evaluates in this order:
+ * 1. (help-locales "") in the gimprc file
+ * 2. the UI language from Preferences/Interface.
+ * On OS X: If the user has set the UI language to 'System Language', then
+ * the UI language from the OS X's System Preferences is returned.
+ */
static gchar *
gimp_help_get_locales (Gimp *gimp)
{
- GimpGuiConfig *config = GIMP_GUI_CONFIG (gimp->config);
+ GimpGuiConfig *config = GIMP_GUI_CONFIG(gimp->config);
+
+#ifdef PLATFORM_OSX
+ NSAutoreleasePool *pool;
+ NSUserDefaults *defaults;
+ NSArray *langArray;
+ NSString *languagesList;
+ gchar *languages = NULL;
+#endif
+ /* First check for preferred help locales in gimprc. */
if (config->help_locales && strlen (config->help_locales))
return g_strdup (config->help_locales);
+ /* If no help locale is preferred, use the locale from Preferences/Interface*/
+#ifdef PLATFORM_OSX
+ /* If GIMP's preferred locale is set to 'System language', then
+ * g_get_language_names()[0] is 'C' and we have to get the value from
+ * the OS X System Preferences.
+ */
+ if (!strcmp(g_get_language_names()[0],"C"))
+ {
+ pool = [[NSAutoreleasePool alloc] init];
+
+ defaults = [NSUserDefaults standardUserDefaults];
+ langArray = [defaults stringArrayForKey: @"AppleLanguages"];
+ /* Although we only need the first entry, get them all. */
+ languagesList = [langArray componentsJoinedByString: @":"];
+
+ /* Translate them from Mac OS X (new UNIX style) to old UNIX style.*/
+ languagesList = [languagesList
+ stringByReplacingOccurrencesOfString: @"az-Latn"
+ withString: @"az"];
+
+ languagesList = [languagesList
+ stringByReplacingOccurrencesOfString: @"ga-dots"
+ withString: @"ga"];
+
+ languagesList = [languagesList
+ stringByReplacingOccurrencesOfString: @"mn-Cyrl"
+ withString: @"mn"];
+
+ languagesList = [languagesList
+ stringByReplacingOccurrencesOfString: @"ms-Latn"
+ withString: @"ms"];
+
+ languagesList = [languagesList
+ stringByReplacingOccurrencesOfString: @"tg-Cyrl"
+ withString: @"tz"];
+
+ languagesList = [languagesList
+ stringByReplacingOccurrencesOfString: @"tt-Cyrl"
+ withString: @"tt"];
+
+ languagesList = [languagesList
+ stringByReplacingOccurrencesOfString: @"zh-Hans"
+ withString: @"zh_CN"];
+
+ languagesList = [languagesList
+ stringByReplacingOccurrencesOfString: @"zh-Hant"
+ withString: @"zh_TW"];
+
+ languagesList = [languagesList
+ stringByReplacingOccurrencesOfString: @"Arab"
+ withString: @"arabic"];
+
+ languagesList = [languagesList
+ stringByReplacingOccurrencesOfString: @"Cyrl"
+ withString: @"cyrillic"];
+
+ languagesList = [languagesList
+ stringByReplacingOccurrencesOfString: @"Mong"
+ withString: @"mongolian"];
+
+ languagesList = [languagesList
+ stringByReplacingOccurrencesOfString: @"-"
+ withString: @"_"];
+
+ /* Ensure that the default language 'en' is there. */
+ languagesList = [languagesList stringByAppendingString: @":en"];
+
+ languages = g_strdup ([languagesList UTF8String]);
+
+ [pool drain];
+ return languages;
+ }
+ else
+ return g_strjoinv (":", (gchar **) g_get_language_names ());
+#else
return g_strjoinv (":", (gchar **) g_get_language_names ());
+#endif
+
}
static gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]