Page 1 of 1

wxLocale: how to use multiple locales for wxString?

Posted: Sun Nov 17, 2019 2:12 pm

I have an application that needs to use "C" style locale instead of the default locale.
The reason is that for my default loclale PI converts to 3,1415 instead of 3.1415.

So in C (win 32), i use to use the C' locale:

Code: Select all

_locale_t localeC = _create_locale(LC_ALL, "C");
wchar_t buf[255];

And as expected: i get buf = 3.1415 instead of the default 3,1415 if i do not change the locale.

My question: How does one to this in wxWidgets properly?
I created a wxLocale object mĀ°loc in my APP and used m_loc.Init() to activate the default locale.
So all wxString functions behave according to the current locale.

But if I need a local "locale" in 1 thread and 1 function, how does one do this?

Do I need to add multiple languages to the m_loc object?
Do I need to create multiple wxLocale objects?
How do I select the alternative wxLocale for the wxString::Printf("%g") function?
How do I select the second locale only for the current thread?

Best Regards,