X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fwx_util.cc;h=1a7b73faffe42e54cd064ed58d3776fcc7f734a3;hb=318d819afd66b76e3ea7ce728452c2fb668c0b80;hp=720a058cb771425b67f0828aed0ba7f9fb8deb63;hpb=53eb16342d492236aca77e4b73c0911a5d5eec9f;p=dcpomatic.git diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 720a058cb..1a7b73faf 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, _("DVD-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 +dvdomatic_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 DVDOMATIC_WINDOWS + locale->AddCatalogLookupPathPrefix (std_to_wx (mo_path().string())); +#endif + + locale->AddCatalog (wxT ("libdvdomatic-wx")); + locale->AddCatalog (wxT ("dvdomatic")); + + if (!locale->IsOk()) { + delete locale; + locale = new wxLocale (wxLANGUAGE_ENGLISH); + language = wxLANGUAGE_ENGLISH; + } + } + + if (locale) { + dvdomatic_setup_gettext_i18n (wx_to_std (locale->GetCanonicalName ())); + } +}