Re: Problem with locale on Win32



Andrew E. Makeev writes:
 > As I've discovered, that GTK_LOCALEDIR tries to get installation path by 
 > GETTEXT_PACKAGE define.

You mean from the Registry, by passing GETTEXT_PACKAGE to
g_win32_get_package_installation_subdirectory()?

True, but that is more or less deprecated. If you don't have either of
HKCU\Software\gtk20\InstallationDirectory or
HKLM\Software\gtk20\InstallationDirectory in the Registry, it looks up
where the DLL is located and constructs the path to the locale
directory from that. This is a much more recommended way.

 > Probably, the problem is here, because we have built gettext dll on one 
 > machine, then copy dll in some directory on other machine.

No, that shouldn't be any problem.

Do you have a 3rd-party input module listed in the gtk.immodules file?
Does that module use the "gtk20" translation domain, but a different
"locale" directory for its message catalog than GTK+ does?

I think there is a bug in gtkimmulticontext.c: If one of the entries
in gtk.immodules uses GTK+'s translation domain ("gtk20"), but has its
message catalogs in another place, the
gtk_im_multicontext_append_menuitems() code will call bindtextdomain()
to assign that other directory to the "gtk20" domain. Now it there
then actually exists a message catalog for the gtk20 domain there (but
which is only for the input module in question, not GTK+'s real
message catalog), I guess GTK will forget its translations, as you
describe.

Try this patch:

Index: gtk/gtkimmulticontext.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkimmulticontext.c,v
retrieving revision 1.33
diff -p -u -2 -r1.33 gtkimmulticontext.c
--- gtk/gtkimmulticontext.c	20 Mar 2005 07:01:22 -0000	1.33
+++ gtk/gtkimmulticontext.c	23 Sep 2005 13:52:37 -0000
@@ -495,4 +495,24 @@ 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 both slashes 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:
@@ -523,9 +543,17 @@ gtk_im_multicontext_append_menuitems (Gt
 	{
 	  if (strcmp (contexts[i]->domain, GETTEXT_PACKAGE) == 0 &&
-	      strcmp (contexts[i]->domain_dirname, GTK_LOCALEDIR) == 0)
+	      pathnamecmp (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 if (strcmp (contexts[i]->domain, GETTEXT_PACKAGE) == 0)
+	    /* Input method has own message catalog but uses the same
+	     * translation domain as GTK+ itself. We can't use it as
+	     * that would mean GTK+ forgets its own message
+	     * catalog.
+	     */
+	    g_warning ("Input method %s should not use GTK's translation domain %s",
+		       contexts[i]->context_id, GETTEXT_PACKAGE);
 	  else
-	    /* Input method has own message catalog */
+	    /* Input method has own translation domain and message catalog */
 	    {
 	      bindtextdomain (contexts[i]->domain,


--tml




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