wxApp::Initialize() setting the locale? [wxGTK 2.8.0]
Vadim Zeitlin
vadim at wxwindows.org
Sun Mar 4 12:20:04 PST 2007
[redirected to wx-dev from wx-users as it seems more appropriate]
On Tue, 27 Feb 2007 13:28:36 -0400 Ian Britten <britten at caris.com> wrote:
IB> After some debugging/digging, I noticed that wxApp::Initialize() (wxGTK)
IB> explicitely calls gtk_set_locale(), setting the program locale to be
IB> the same as the users current settings.
For the reference, this call was added by Robert 8.5 years ago in revision
1.13 of src/gtk/window.cpp with the following commit message:
Added support for non-european fonts and X extension using gtk_set_locale()
So apparently it is needed to use i18n with GTK+ at all and so it seems
like a good idea to have it.
IB> Given that large amounts of our code is currently not ready for a
IB> wholesale locale switch, I'm unsure how to proceed... I can't
IB> currently support foreign locales, and if the user has switched their
IB> locale, I know that the app won't work correctly.
I do see your point as well though.
IB> If I try to work around this (by trying to set the locale back to C),
IB> how much of the wx subsystem will be left in the 'other' locale?
IB> Can it be reset/switched?
I think this is going to result in problems.
IB> Finally, can anyone clarify the behaviour of wxMSW? Obviously there's
IB> no call to gtk_set_locale() in there, but I didn't see anything that
IB> seems to be setting the locale. Does this mean that wxMSW behaves
IB> differently than wxGTK? (Sorry, I'm not familiar with Windows, and
IB> don't have a Windows box to test on...)
Yes, wxMSW doesn't change the locale and it's indeed an inconsistency
between ports and so is a bad thing. However my way of solving it would be
to add setlocale(LC_ALL, "") call to wxMSW startup code somewhere rather
than removing gtk_set_locale() from wxGTK.
But as I wrote above, I realize that some applications may not want to
change locale at all. So ideally we should provide a possibility to avoid
this even though I think it should still be done by default. The simplest
way to allow for it would be to add a virtual wxApp SetLocale() function
which would be called from OnInit() and could be overridden by the user
code to do nothing.
What do you think?
VZ
More information about the wx-dev
mailing list