After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 720096 - New function to set the default direction of the locale.
New function to set the default direction of the locale.
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other All
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
: 720200 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-12-09 10:20 UTC by Jehan
Modified: 2014-09-04 08:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
New function gtk_get_locale_direction() (3.17 KB, patch)
2013-12-09 10:20 UTC, Jehan
none Details | Review
Gettext comment for "default:LTR" must be before the string (1.09 KB, patch)
2013-12-11 01:07 UTC, Jehan
committed Details | Review

Description Jehan 2013-12-09 10:20:12 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!). :-)
Comment 1 Jehan 2013-12-09 10:22:13 UTC
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!).
Comment 2 Matthias Clasen 2013-12-09 13:32:23 UTC
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.
Comment 3 Jehan 2013-12-09 21:32:18 UTC
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.
Comment 4 Matthias Clasen 2013-12-10 21:29:48 UTC
*** Bug 720200 has been marked as a duplicate of this bug. ***
Comment 5 Jehan 2013-12-11 01:07:35 UTC
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.
Comment 6 Matthias Clasen 2013-12-11 04:31:59 UTC
Attachment 263955 [details] pushed as 57f5901 - Gettext comment for "default:LTR" must be before the string