GNOME Bugzilla – Bug 448201
Translate g_option_context_new text
Last modified: 2007-06-18 05:36:34 UTC
The program description, which appears after starting with --help, is marked for translation, but the translated text doesn't shows up.
Created attachment 90070 [details] [review] Trivial fix, using g_option_context_set_translation_domain
g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); Doesn;t the third param set this already? Atleast the devhelp says so. If it doesn't work, may be a glib bug?
I don't know, if it sets or should set - if I run evolution --help, the text doesn't appear translated, with the patch, it appears translated. I got the idea from this comment: http://bugzilla.gnome.org/show_bug.cgi?id=445865#c3 While updating the patch of that bug, I played a bit with N_(), _() and g_option_context_set_translation_domain, and only the last one showed translated the string. Then I started to check other apps, and several other (file-roller, evince, evolution, etc.) seem to have this problem too. However, gedit doesn't, and this is really strange, as it uses _() to translate the context and the sring appears translated. The trick is, that gedit uses setlocale (LC_ALL, ""); before the bindtextdomain() call: http://svn.gnome.org/viewcvs/gedit/trunk/gedit/gedit.c?revision=5369&view=markup so that it can translate the context with the _() macro. So my opinion is, that either setlocale, or g_option_context_set_translation_domain should be used in order to correctly translate the context information. I don't know which one is the best practice.
g_option_context_add_main_entries () void g_option_context_add_main_entries (GOptionContext *context, const GOptionEntry *entries, const gchar *translation_domain); A convenience function which creates a main group if it doesn't exist, adds the entries to it and sets the translation domain. This is the API spec. I think if it doesn't work, may be worth filling this in glib. Im fine to push it meanwhile.
After reading the docs, seems that g_option_context_add_main_entries () is for translating _only_ the description and arg_description fields of GOptionEntry's, (and adding an array of those to a context). To translate the context (g_option_context_new ()), summary (g_option_context_set_summary ()) and description (g_option_context_set_description ()) of a GOptionContext, you need to use g_option_context_set_translate_func (), for which g_option_context_set_translation_domain () is a convenience function. Strange indeed, but this seems to be the intended usage, if I don't get it wrong.
Committed to head.