Be careful to not override GTK+ translations with the translations of the

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.
This commit is contained in:
Matthias Clasen 2006-12-23 21:25:16 +00:00 committed by Matthias Clasen
parent dfbde7a8d8
commit c851a85dc3
3 changed files with 64 additions and 12 deletions

View File

@ -1,5 +1,12 @@
2006-12-23 Matthias Clasen <mclasen@redhat.com> 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 * gtk/gtkimcontextsimple.c: Allow composing l with
stroke. (#349638, Daniel Lublin) stroke. (#349638, Daniel Lublin)

View 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: * gtk_im_multicontext_append_menuitems:
* @context: a #GtkIMMultiContext * @context: a #GtkIMMultiContext
@ -488,15 +508,35 @@ gtk_im_multicontext_append_menuitems (GtkIMMulticontext *context,
GtkWidget *menuitem; GtkWidget *menuitem;
const gchar *translated_name; const gchar *translated_name;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
if (contexts[i]->domain && contexts[i]->domain_dirname && if (contexts[i]->domain && contexts[i]->domain[0])
contexts[i]->domain[0] && contexts[i]->domain_dirname[0])
{ {
if (strcmp (contexts[i]->domain, GETTEXT_PACKAGE) == 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 */ /* 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); translated_name = _(contexts[i]->context_name);
}
else else
/* Input method has own message catalog */ {
/* 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, bindtextdomain (contexts[i]->domain,
contexts[i]->domain_dirname); contexts[i]->domain_dirname);
@ -505,10 +545,15 @@ gtk_im_multicontext_append_menuitems (GtkIMMulticontext *context,
#endif #endif
translated_name = dgettext (contexts[i]->domain, contexts[i]->context_name); 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 else
/* Either domain or domain_dirname is NULL or "". We assume that /* Empty or NULL domain. We assume that input method does not
* input method does not want a translated name in this case * want a translated name in this case.
*/ */
translated_name = contexts[i]->context_name; translated_name = contexts[i]->context_name;
#else #else

View File

@ -89,8 +89,8 @@ cedilla_init (GtkIMContextSimple *im_context)
static const GtkIMContextInfo cedilla_info = { static const GtkIMContextInfo cedilla_info = {
"cedilla", /* ID */ "cedilla", /* ID */
N_("Cedilla"), /* Human readable name */ N_("Cedilla"), /* Human readable name */
"gtk+", /* Translation domain */ GETTEXT_PACKAGE, /* Translation domain */
GTK_LOCALEDIR, /* Dir for bindtextdomain (not strictly needed for "gtk+") */ GTK_LOCALEDIR, /* Dir for bindtextdomain */
"az:ca:co:fr:gv:oc:pt:sq:tr:wa" /* Languages for which this module is the default */ "az:ca:co:fr:gv:oc:pt:sq:tr:wa" /* Languages for which this module is the default */
}; };