]> Pileus Git - ~andy/gtk/commitdiff
Be careful to not override GTK+ translations with the translations of the
authorMatthias Clasen <mclasen@redhat.com>
Sat, 23 Dec 2006 21:25:16 +0000 (21:25 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sat, 23 Dec 2006 21:25:16 +0000 (21:25 +0000)
2006-12-23  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkimmulticontext.c: Be careful to not override
        GTK+ translations with the translations of the input
        method.  (#317080, Tor Lillqvist)

        * modules/input/imcedilla.c: Use standard macros
        for translation domain and locale dir.

ChangeLog
gtk/gtkimmulticontext.c
modules/input/imcedilla.c

index dafe8dee35a29955c4315d39939540091f482b8e..330bbe9c18c063afff2318cc313db27789bbd958 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2006-12-23  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkimmulticontext.c: Be careful to not override
+       GTK+ translations with the translations of the input
+       method.  (#317080, Tor Lillqvist)
+
+       * modules/input/imcedilla.c: Use standard macros
+       for translation domain and locale dir.
+
        * gtk/gtkimcontextsimple.c: Allow composing l with 
        stroke.  (#349638, Daniel Lublin)
 
index 95760171e65ba62536fb453eac22f48853118e88..b1b1c913c6cc420efa266a8bab5e45ed7b7b5ec2 100644 (file)
@@ -464,6 +464,26 @@ activate_cb (GtkWidget         *menuitem,
     }
 }
 
+static int
+pathnamecmp (const char *a,
+            const char *b)
+{
+#ifndef G_OS_WIN32
+  return strcmp (a, b);
+#else
+  /* Ignore case insensitivity, probably not that relevant here. Just
+   * make sure slash and backslash compare equal.
+   */
+  while (*a && *b)
+    if ((G_IS_DIR_SEPARATOR (*a) && G_IS_DIR_SEPARATOR (*b)) ||
+       *a == *b)
+      a++, b++;
+    else
+      return (*a - *b);
+  return (*a - *b);
+#endif
+}
+
 /**
  * gtk_im_multicontext_append_menuitems:
  * @context: a #GtkIMMultiContext
@@ -488,15 +508,35 @@ gtk_im_multicontext_append_menuitems (GtkIMMulticontext *context,
       GtkWidget *menuitem;
       const gchar *translated_name;
 #ifdef ENABLE_NLS
-      if (contexts[i]->domain && contexts[i]->domain_dirname &&
-         contexts[i]->domain[0] && contexts[i]->domain_dirname[0])
+      if (contexts[i]->domain && contexts[i]->domain[0])
        {
-         if (strcmp (contexts[i]->domain, GETTEXT_PACKAGE) == 0 &&
-             strcmp (contexts[i]->domain_dirname, GTK_LOCALEDIR) == 0)
-           /* Input method may have a name in the GTK+ message catalog */
-           translated_name = _(contexts[i]->context_name);
-         else
-           /* Input method has own message catalog */
+         if (strcmp (contexts[i]->domain, GETTEXT_PACKAGE) == 0)
+           {
+             /* Same translation domain as GTK+ */
+             if (!(contexts[i]->domain_dirname && contexts[i]->domain_dirname[0]) ||
+                 pathnamecmp (contexts[i]->domain_dirname, GTK_LOCALEDIR) == 0)
+               {
+                 /* Empty or NULL, domain directory, or same as
+                  * GTK+. Input method may have a name in the GTK+
+                  * message catalog.
+                  */
+                 translated_name = _(contexts[i]->context_name);
+               }
+             else
+               {
+                 /* Separate domain directory but the same
+                  * translation domain as GTK+. We can't call
+                  * bindtextdomain() as that would make GTK+ forget
+                  * its own messages.
+                  */
+                 g_warning ("Input method %s should not use GTK's translation domain %s",
+                            contexts[i]->context_id, GETTEXT_PACKAGE);
+                 /* Try translating the name in GTK+'s domain */
+                 translated_name = _(contexts[i]->context_name);
+               }
+           }
+         else if (contexts[i]->domain_dirname && contexts[i]->domain_dirname[0])
+           /* Input method has own translation domain and message catalog */
            {
              bindtextdomain (contexts[i]->domain,
                              contexts[i]->domain_dirname);
@@ -505,10 +545,15 @@ gtk_im_multicontext_append_menuitems (GtkIMMulticontext *context,
 #endif
              translated_name = dgettext (contexts[i]->domain, contexts[i]->context_name);
            }
+         else
+           {
+             /* Different translation domain, but no domain directory */
+             translated_name = contexts[i]->context_name;
+           }
        }
       else
-       /* Either domain or domain_dirname is NULL or "". We assume that
-        * input method does not want a translated name in this case
+       /* Empty or NULL domain. We assume that input method does not
+        * want a translated name in this case.
         */
        translated_name = contexts[i]->context_name;
 #else
index 061bdedd73c9207906b239cd7ded5356bd65338e..5914a6686a7914c986d390caa86748802e82ebd1 100644 (file)
@@ -89,8 +89,8 @@ cedilla_init (GtkIMContextSimple *im_context)
 static const GtkIMContextInfo cedilla_info = { 
   "cedilla",                      /* ID */
   N_("Cedilla"),                   /* Human readable name */
-  "gtk+",                         /* Translation domain */
-   GTK_LOCALEDIR,                 /* Dir for bindtextdomain (not strictly needed for "gtk+") */
+  GETTEXT_PACKAGE,                /* Translation domain */
+  GTK_LOCALEDIR,                  /* Dir for bindtextdomain */
   "az:ca:co:fr:gv:oc:pt:sq:tr:wa"  /* Languages for which this module is the default */
 };