summaryrefslogtreecommitdiff
path: root/src/wx/wx_util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-05-25 14:22:30 +0200
committerCarl Hetherington <cth@carlh.net>2025-05-27 09:36:37 +0200
commit5661c34574fdac778dba0e3c3503f5792c41bb3c (patch)
treebd1022ef2dae2abe880714123bfebdb868edc91b /src/wx/wx_util.cc
parenta8f06a40096a0cbd56c42602f8dc1ce4857af0d8 (diff)
Move i18n setup into 3 separate platform files.
Diffstat (limited to 'src/wx/wx_util.cc')
-rw-r--r--src/wx/wx_util.cc116
1 files changed, 0 insertions, 116 deletions
diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc
index 932e4e0bd..afea3b209 100644
--- a/src/wx/wx_util.cc
+++ b/src/wx/wx_util.cc
@@ -421,122 +421,6 @@ checked_set(RegionSubtagWidget* widget, optional<dcp::LanguageTag::RegionSubtag>
}
-#ifdef DCPOMATIC_OSX
-
-void
-dcpomatic_setup_i18n()
-{
- wxLog::EnableLogging();
-
-#if wxCHECK_VERSION(3, 1, 6)
- wxUILocale::UseDefault();
-#endif
-
- auto get_locale_value = [](CFLocaleKey key) {
- CFLocaleRef cflocale = CFLocaleCopyCurrent();
- auto value = (CFStringRef) CFLocaleGetValue(cflocale, key);
- char buffer[64];
- CFStringGetCString(value, buffer, sizeof(buffer), kCFStringEncodingUTF8);
- CFRelease(cflocale);
- return string(buffer);
- };
-
- auto translations = new wxTranslations();
-
- auto config_lang = Config::instance()->language();
- if (config_lang && !config_lang->empty()) {
- translations->SetLanguage(std_to_wx(*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,
- * but with the preferred language set to English).
- *
- * Instead, the the language code from macOS then get the corresponding canonical language string with region,
- * which wxTranslations::SetLanguage will accept.
- */
- auto const language_code = get_locale_value(kCFLocaleLanguageCode);
- /* 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 wxCHECK_VERSION(3, 1, 6)
- translations->SetLanguage(info->GetCanonicalWithRegion());
-#else
- translations->SetLanguage(info->CanonicalName);
-#endif
- }
- }
-
-#ifdef DCPOMATIC_DEBUG
- wxFileTranslationsLoader::AddCatalogLookupPathPrefix(char_to_wx("build/src/wx/mo"));
- wxFileTranslationsLoader::AddCatalogLookupPathPrefix(char_to_wx("build/src/tools/mo"));
-#endif
-
- translations->AddStdCatalog();
- translations->AddCatalog(char_to_wx("libdcpomatic2-wx"));
- translations->AddCatalog(char_to_wx("dcpomatic2"));
-
- wxTranslations::Set(translations);
-
- dcpomatic_setup_gettext_i18n(config_lang.get_value_or(""));
-}
-
-#else
-
-void
-dcpomatic_setup_i18n ()
-{
- int language = wxLANGUAGE_DEFAULT;
-
- auto config_lang = Config::instance()->language ();
- if (config_lang && !config_lang->empty ()) {
- auto const li = wxLocale::FindLanguageInfo (std_to_wx (config_lang.get ()));
- if (li) {
- language = li->Language;
- }
- }
-
- wxLocale* locale = nullptr;
- if (wxLocale::IsAvailable (language)) {
- locale = new wxLocale (language, wxLOCALE_LOAD_DEFAULT);
-
-#ifdef DCPOMATIC_WINDOWS
- locale->AddCatalogLookupPathPrefix (std_to_wx (mo_path().string()));
- locale->AddCatalog(char_to_wx("wxstd-3.1"));
-#endif
-
-#ifdef DCPOMATIC_LINUX
- locale->AddCatalogLookupPathPrefix(std_to_wx(LINUX_LOCALE_PREFIX));
-
- /* We have to include the wxWidgets .mo in our distribution,
- so we rename it to avoid clashes with any other installation
- of wxWidgets.
- */
- locale->AddCatalog(char_to_wx("dcpomatic2-wxstd"));
-
- /* Fedora 29 (at least) installs wxstd3.mo instead of wxstd.mo */
- locale->AddCatalog(char_to_wx("wxstd3"));
-#endif
-
- locale->AddCatalog(char_to_wx("wxstd"));
- locale->AddCatalog(char_to_wx("libdcpomatic2-wx"));
- locale->AddCatalog(char_to_wx("dcpomatic2"));
-
- if (!locale->IsOk()) {
- delete locale;
- locale = new wxLocale (wxLANGUAGE_ENGLISH);
- }
- }
-
- if (locale) {
- dcpomatic_setup_gettext_i18n (wx_to_std (locale->GetCanonicalName ()));
- }
-}
-
-#endif
-
-
int
wx_get (wxSpinCtrl* w)
{