I am using this code to use the system default locale for formatting dates regardless of the language chosen by the user for the program.
It allows users to use the program in, for example, English (because there are no translations for their language) and still have dates in their usual formatting.
m_locale.Init( wxLANGUAGE_DEFAULT, wxLOCALE_DONT_LOAD_DEFAULT ); wxTranslations* const trans = new wxTranslations(); trans->SetLanguage( m_lang ); wxTranslations::Set( trans );
Up to and including wxWidgets-3.1.5, this worked fine on both Windows and Linux.
On Windows, it still works with the current master. But on Linux it doesn't work any longer.
It now seems that the English locale is used by default under Linux instead of that of the system.
To Reproduce
The issue can be reproduced by using this modified internat sample: internat_cpp.zip
If runnig the sample on, for example, a German Ubuntu 18.04.:
With wxWidgets-3.1.5 it uses the default locale of the system for formatting the date.

With the latest master, the English locale seems to be used instead.

Platform and version information
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
The reason seems to be that wxSetlocale(LC_ALL, "") is no longer called for wxLANGUAGE_DEFAULT under Linux.
Maybe this regression could be fixed as follows?
diff --git "a/src/unix/uilocale.cpp" "b/src/unix/uilocale.cpp" index b9ba860e10..5cf41c9acd 100644 --- "a/src/unix/uilocale.cpp" +++ "b/src/unix/uilocale.cpp" @@ -260,7 +260,8 @@ wxUILocaleImplUnix::Use() { if ( m_locId.IsEmpty() ) { - // This is the default locale, it is already in use. + // The default locale is to be used. + wxSetlocale(LC_ALL, ""); return; }
I don't know if this is the correct fix or if this change has any side effects, but with this change applied it seems to work as before (up to and including wxWidgets-3.1.5).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Yes, I think it makes sense, as the comment here https://github.com/wxWidgets/wxWidgets/blob/af9e7fd4609381e2086a13a603e5e46e64718a77/src/common/intl.cpp#L755-L756 says, wxUILocale is supposed to call setlocale() under Unix. I'll include it my upcoming locale-related PR.
Thanks for reporting this!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()