#60606 - automatically set locale
- From: Owen Taylor <otaylor redhat com>
- To: gtk-devel-list gnome org
- Subject: #60606 - automatically set locale
- Date: 03 Oct 2001 16:45:33 -0400
Bug #60606 suggests that gtk_init() should automatically call
setlocale (LC_ALL, "") and do the other set up done currently
by gtk_set_locale().
The advantage of this is that almost all apps should be calling this
function, or otherwise:
   
 - The user won't see localization of GTK+ dialogs, of 
   strftime() and other C library functions.
 - Handling of anything that goes through charset-of-locale
   won't work correctly. For instance, g_utf8_strcoll()
   on some systems will convert to charset-of-locale before
   comparing. If the user is using characters in the locale's
   charset but not in ASCII, this will produce odd results.
   The more GTK+ and GLib can work natively in UTF-8, the
   less this is an issue; it is _much_ less of an issue
   than in GTK+-1.2 where text display is completely broken
   unless the locale is set.
Having to have (non-portable-to-Windows) magic:
 #include <locale.h>
 
 int main
 {
   setlocale (LC_ALL, "");
 }
In our hello-world doesn't look very good for GTK+.
   
Disadvantages of this:
 - Naive apps that except things like isalpha() and strtod()
   to work as in the C locale may be caught by suprise.
 - Doing the set-LC_NUMERIC-to_C trick becomes a little
   different - you have to set LC_NUMERIC back after
   calling gtk_init(), not after calling gtk_set_locale().
 - Conservative Unix types probably will consider it
   not GTK+'s business to set the locale.
   After all, you have to call setlocale() yourself 
   if you are writing a shell program.
All in all, I think it would be a positive change, and will
go ahead and make the change unless people have good reasons
to suggest why we shouldn't do it.
The plan, in detail would then be:
 - Add a gtk_disable_setlocale() call that you can
   use to make GTK+ not call setlocale().
 - If this has not been calle,d to setlocale (LC_ALL, "") as
   the first thing in gtk_init()
 - Automatically do the rest of the stuff (initializing X for 
   the locale) that we do in gtk_set_locale() in gtk_init() 
   even if you call gtk_disable_setlocale(), so you can 
   do:
    gtk_disable_setlocale();
    setlocale (LC_ALL, "");
    setlocale (LC_NUMERIC, "C");
 
    gtk_init();
   And it will work properly.
Regards,
                                        Owen
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]