GNOME Bugzilla – Bug 303381
numerical widgets use European digits in locales with localized digits
Last modified: 2018-05-02 14:09:19 UTC
Please describe the problem: when we start a session in a language where numbers are written in a script other than Latin, the gtk numerical widgets are still shown in latin. Steps to reproduce: 1. launch something with numerical widgets, e. g. gedit in say, Persian locale: LANG=fa_IR gedit 2. go to edit, preferences Actual results: the numerical widgets are shown in latin script. (screenshot attached) Expected results: the numerical widgets should have been displayed in localized (here: Persian) script characters. Does this happen every time? yes Other information:
Created attachment 46131 [details] a screenshot demonstrating latin numbers in gtk treeview widgets
This is not a GtkTreeView specific bug, moving to main GTK+.
This would definitley need configure checks to see if the necessary format modifiers were supported. Would it also need a preference? Do all users in those locales want localized digits in spinbuttons (and so forth)?
About a preference, I do not think so, but whether the widgets should have a property to use ASCII or locale numerals, I'm not sure. I cannot think of any obvious place that ASCII is required in Persian.
They won't need a preference, no. Users would prefer to always see localized digits. Currently, the only glibc locale to use alternative digits is the Persian for Iran locale. Some Arab country users *may* want to be able to switch between digit forms, *if* the maintainer of the Arabic locales decides to switch to Arabic-Indic digit forms, but I see that as a lower-level setting, to appear desktop-wide, possibly best to happen in the same glibc level, e.g. by having a personal locale data file. BTW, we don't have spinbuttons in hex, do we? If we do, those would need to remain in ASCII (glibc doesn't support the "I" flag for "%x" anyway). Only decimal numbers (both integer and float) need to use localized digits.
Attach a patch then. ;) I think we can start by always using localized digits. If we decide that we need ASCII digits for any reason, we can always add the property later.
The glibc library is not yet capable of reading localized digits in floats, which is what is needed for spinbuttons, but a patch has been submitted: http://sourceware.org/ml/libc-alpha/2005-06/msg00138.html There are two options to fix this bug: 1) One is to wait for the incorporation of the patch in glibc and then substitute the g_strtod() call with an equivalent scanf("%If", ...) in "gtk/gtkspinbutton.c". This means more waiting, and the support only being available on plaforms using glibc. 2) The other is to implement the code for reading localized digits in glib or gtk to make it handle localized digits. This means duplication of code, but could also be implemented independent of the locale to some degree, like by accepting all Unicode characters of the type decimal digit. Owen, what do you think? I am attaching a proof-of-concept patch. This will probably crash under any other locale but fa_IR (and leaks memory under fa_IR). But it implements the feature in spinbuttons.
Created attachment 51108 [details] [review] gtk patch (don't run it, it will eat your dog)
Created attachment 51109 [details] [review] glib patch (this will eat the same dog again)
Roozbeh, I believe we want to go with option 1. For one reason, I don't like option 2 (accepting all decimal digit sets), and the other reason is, for broader support, we would simply wait for the glocale project instead of stuffing in more bits into glib... A complete patch is appreciated. :)
Can we start by a patch to use localized digits in output?
(In reply to comment #12) > Can we start by a patch to use localized digits in output? If we are just talking about spinbuttons, I don't think so. The current spinbutton code works by keeping a string in the widget, and uses g_strtod when it needs to get the value back. So we need to take care of the previously output digits in g_strtod or one can never read the widget.
Apparently one also needs to fix the number checking code in the gtk_spin_button_insert_text function to accept the localized digits and decimal separator.
*** Bug 528351 has been marked as a duplicate of this bug. ***
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/247.