wxLocale::Init( wxLANGUAGE_DEFAULT ) doesn't work any longer under Linux (Issue #22212)

69 views
Skip to first unread message

taler21

unread,
Mar 21, 2022, 8:24:04 AM3/21/22
to wx-...@googlegroups.com, Subscribed

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.
locale-default_wx-315

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

Platform and version information

  • wxWidgets version you use: Latest master of upcoming 3.1.6
  • wxWidgets port you use: wxGTK
  • OS and its version: Ubuntu 18.04
  • For wxGTK only:
    • GTK version: 2.24.31
    • Which GDK backend is used: X11


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/22212@github.com>

taler21

unread,
Mar 23, 2022, 8:44:13 AM3/23/22
to wx-...@googlegroups.com, Subscribed

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.Message ID: <wxWidgets/wxWidgets/issues/22212/1076333533@github.com>

VZ

unread,
Mar 23, 2022, 11:10:45 AM3/23/22
to wx-...@googlegroups.com, Subscribed

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.Message ID: <wxWidgets/wxWidgets/issues/22212/1076476980@github.com>

VZ

unread,
Mar 24, 2022, 4:40:52 PM3/24/22
to wx-...@googlegroups.com, Subscribed

Closed #22212 via 4a9da94.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/22212/issue_event/6302487485@github.com>

Reply all
Reply to author
Forward
0 new messages