GNOME Bugzilla – Bug 720096
New function to set the default direction of the locale.
Last modified: 2014-09-04 08:23:40 UTC
Created attachment 263804 [details] [review] New function gtk_get_locale_direction() GTK+ has currently this nice trick to get the locale default direction and apply it to widget direction (so that RTL language also get RTL ui, as expected) with gtk_widget_set_default_direction(). It is applied automatically as a parse hook set with gtk_get_option_group(). That's nice but it means this can be set only at command line parsing when using g_option_context_parse(). A program cannot use this direction detection for instance if they don't use g_option_context_parse() or if ever they change the program language after the command line parsing. This is for instance the case in GIMP, where the user can set a language different from the system one through the Preferences dialog. Unfortunately this change happens after command line parsing, and we have this bug where the user-set lang is correctly set but the UI is in the wrong direction: bug 679214. Our only possible fix currently is to reproduce GTK+ direction detection code into GIMP. Thus I propose the attached patch to GTK+. It basically extracts the language base direction detection code into its own function gtk_get_locale_direction() that we can now use nicely into any application (and we will in GIMP!). :-)
Note: the attached patch has been made against origin/gtk-2-24 branch, but it can as well go in the master branch. I'm sure it will be useful for GTK+ 3 application as well (for instance GIMP 3 when it will be finally out!).
Changing language at runtime is not guaranteed to work at all. You might be able to patch up this particular issue, but there will be others.
In GIMP, changing UI language requires a program restart. Then when GIMP starts, we change the language at the very beginning of the run, during initialization, but still after command line processing, which is the very very beginning (obviously because we need to parse command line options before initialization, since they can influence it). So we don't really change the language at runtime, at least not any time during runtime, only at initialization. And in any case, there is no reason to tie this particular logics (direction settings of widgets) to command line processing.
*** Bug 720200 has been marked as a duplicate of this bug. ***
Created attachment 263955 [details] [review] Gettext comment for "default:LTR" must be before the string I see it made it to master. Thanks. Except that I realized that my code had a minor bug. The comment had to be just before the gettext string to be considered also a gettext comment and end up in the po file. This is obviously an important message to translators, so that they know how to "translate" this string. Attached patch to fix this.
Attachment 263955 [details] pushed as 57f5901 - Gettext comment for "default:LTR" must be before the string