From 2aea5e99b0fc774d8539feac92224ca1caa823c7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 23 May 2025 23:27:48 +0200 Subject: Fix wx i18n code. --- src/wx/wx_util.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 3e5dd7b76..ed1513ceb 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -40,6 +40,7 @@ #include "lib/version.h" #include #include +#include LIBDCP_DISABLE_WARNINGS #include #include @@ -443,9 +444,12 @@ dcpomatic_setup_i18n() auto translations = new wxTranslations(); + string lib_lang; + auto config_lang = Config::instance()->language(); if (config_lang && !config_lang->empty()) { translations->SetLanguage(std_to_wx(*config_lang)); + lib_lang = *config_lang; } else { /* We want to use the user's preferred language. It seems that if we use the wxWidgets default we will get the * language for the locale, which may not be what we want (e.g. for a machine in Germany, configured for DE locale, @@ -455,11 +459,11 @@ dcpomatic_setup_i18n() * which wxTranslations::SetLanguage will accept. */ auto const language_code = get_locale_value(kCFLocaleLanguageCode); + lib_lang = fmt::format("{}_{}", language_code, get_locale_value(kCFLocaleCountryCode)); /* Ideally this would be wxUILocale (as wxLocale is deprecated) but we want to keep this building * with the old wxWidgets we use for the older macOS builds. */ - auto const info = wxLocale::FindLanguageInfo(std_to_wx(language_code)); - if (info) { + if (auto const info = wxLocale::FindLanguageInfo(std_to_wx(language_code))) { #if wxCHECK_VERSION(3, 1, 6) translations->SetLanguage(info->GetCanonicalWithRegion()); #else @@ -488,7 +492,7 @@ dcpomatic_setup_i18n() wxTranslations::Set(translations); - dcpomatic_setup_c_and_gettext_i18n(config_lang.get_value_or("")); + dcpomatic_setup_c_and_gettext_i18n(lib_lang); } #else -- cgit v1.2.3