[gtk-mac-integration: 1/2] Fix localization for application bundles




commit 673893b4ef4e72707e14b032c25179b5a3f84b1b
Author: ReneĢ de Hesselle <dehesselle web de>
Date:   Mon Jun 28 14:12:20 2021 +0200

    Fix localization for application bundles
    
    Add a check if we're running inside an application bundle and rebind
    the text domain to <resource_path>/share/locale.

 src/gtkosxapplication_quartz.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/src/gtkosxapplication_quartz.c b/src/gtkosxapplication_quartz.c
index b5161cb..7dc362e 100644
--- a/src/gtkosxapplication_quartz.c
+++ b/src/gtkosxapplication_quartz.c
@@ -593,6 +593,23 @@ gtkosx_application_init (GtkosxApplication *self)
   [NSApp setDelegate: [GtkApplicationDelegate new]];
   self->priv->delegate = [NSApp delegate];
   bindtextdomain (PACKAGE_NAME, LOCALEDIR);
+
+  /* Check if we're running inside an application bundle and overwrite the
+   * previously bound domain to a location inside the bundle.
+   */
+  gchar *bundle_id = gtkosx_application_get_bundle_id();
+  if (bundle_id)
+    {
+      gchar *resource_path = gtkosx_application_get_resource_path();
+      if (resource_path)
+        {
+          gchar *locale_dir = g_strdup_printf("%s/share/locale", resource_path);
+          g_free(resource_path);
+          bindtextdomain (PACKAGE_NAME, locale_dir);
+          g_free(locale_dir);
+        }
+      g_free(bundle_id);
+    }
 }
 
 static void


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