diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-05-25 14:22:30 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-05-27 09:36:37 +0200 |
| commit | 5661c34574fdac778dba0e3c3503f5792c41bb3c (patch) | |
| tree | bd1022ef2dae2abe880714123bfebdb868edc91b /src/wx/i18n_setup_windows.cc | |
| parent | a8f06a40096a0cbd56c42602f8dc1ce4857af0d8 (diff) | |
Move i18n setup into 3 separate platform files.
Diffstat (limited to 'src/wx/i18n_setup_windows.cc')
| -rw-r--r-- | src/wx/i18n_setup_windows.cc | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/wx/i18n_setup_windows.cc b/src/wx/i18n_setup_windows.cc new file mode 100644 index 000000000..0fc4ecdd5 --- /dev/null +++ b/src/wx/i18n_setup_windows.cc @@ -0,0 +1,62 @@ +/* + Copyright (C) 2025 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#include "i18n_setup.h" +#include "wx_util.h" +#include "lib/i18n_setup.h" +#include <wx/wx.h> + + + +void +dcpomatic::wx::setup_i18n() +{ + int language = wxLANGUAGE_DEFAULT; + + auto config_lang = Config::instance()->language(); + if (config_lang && !config_lang->empty()) { + if (auto const li = wxLocale::FindLanguageInfo(std_to_wx(config_lang.get()))) { + language = li->Language; + } + } + + wxLocale* locale = nullptr; + if (wxLocale::IsAvailable(language)) { + locale = new wxLocale(language, wxLOCALE_LOAD_DEFAULT); + + locale->AddCatalogLookupPathPrefix(std_to_wx(mo_path().string())); + locale->AddCatalog(char_to_wx("wxstd-3.1")); + + 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_i18n(wx_to_std(locale->GetCanonicalName())); + } +} + |
