X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fwx_util.cc;h=5691d341a0eba0ff0bd501c666c5032e050648cb;hb=09a9ac376db005a40a351736bcff4077f098825d;hp=3dad6e7fd84ea455edc398bd391207ee2c2ecad0;hpb=afc495f722f89fea0bcc579046d1a5d362e36f69;p=dcpomatic.git diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 3dad6e7fd..5691d341a 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -25,6 +25,8 @@ #include #include #include "wx_util.h" +#include "config.h" +#include "util.h" using namespace std; using namespace boost; @@ -63,6 +65,16 @@ error_dialog (wxWindow* parent, wxString m) d->Destroy (); } +bool +confirm_dialog (wxWindow* parent, wxString m) +{ + wxMessageDialog* d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxYES_NO | wxICON_QUESTION); + int const r = d->ShowModal (); + d->Destroy (); + return r == wxID_YES; +} + + /** @param s wxWidgets string. * @return Corresponding STL string. */ @@ -201,3 +213,39 @@ checked_set (wxRadioButton* widget, bool value) widget->SetValue (value); } } + +void +dcpomatic_setup_i18n () +{ + int language = wxLANGUAGE_DEFAULT; + + boost::optional config_lang = Config::instance()->language (); + if (config_lang && !config_lang->empty ()) { + wxLanguageInfo const * li = wxLocale::FindLanguageInfo (std_to_wx (config_lang.get ())); + if (li) { + language = li->Language; + } + } + + wxLocale* locale = 0; + if (wxLocale::IsAvailable (language)) { + locale = new wxLocale (language, wxLOCALE_LOAD_DEFAULT); + +#ifdef DCPOMATIC_WINDOWS + locale->AddCatalogLookupPathPrefix (std_to_wx (mo_path().string())); +#endif + + locale->AddCatalog (wxT ("libdcpomatic-wx")); + locale->AddCatalog (wxT ("dcpomatic")); + + if (!locale->IsOk()) { + delete locale; + locale = new wxLocale (wxLANGUAGE_ENGLISH); + language = wxLANGUAGE_ENGLISH; + } + } + + if (locale) { + dcpomatic_setup_gettext_i18n (wx_to_std (locale->GetCanonicalName ())); + } +}