#include "static_text.h"
#include "wx_ptr.h"
#include "wx_util.h"
+#include "wx_variant.h"
#include "lib/config.h"
#include "lib/cross.h"
#include "lib/job.h"
#include "lib/job_manager.h"
#include "lib/util.h"
+#include "lib/variant.h"
#include "lib/version.h"
#include <dcp/locale_convert.h>
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
-#include <wx/spinctrl.h>
-#include <wx/splash.h>
-#include <wx/progdlg.h>
#include <wx/filepicker.h>
+#include <wx/progdlg.h>
#include <wx/sizer.h>
+#include <wx/spinctrl.h>
+#include <wx/splash.h>
LIBDCP_ENABLE_WARNINGS
#include <boost/thread.hpp>
void
error_dialog (wxWindow* parent, wxString m, optional<wxString> e)
{
- auto d = make_wx<wxMessageDialog>(parent, m, _("DCP-o-matic"), wxOK | wxICON_ERROR);
+ auto d = make_wx<wxMessageDialog>(parent, m, variant::wx::dcpomatic(), wxOK | wxICON_ERROR);
if (e) {
wxString em = *e;
em[0] = wxToupper (em[0]);
void
message_dialog (wxWindow* parent, wxString m)
{
- auto d = make_wx<wxMessageDialog>(parent, m, _("DCP-o-matic"), wxOK | wxICON_INFORMATION);
+ auto d = make_wx<wxMessageDialog>(parent, m, variant::wx::dcpomatic(), wxOK | wxICON_INFORMATION);
d->ShowModal ();
}
bool
confirm_dialog (wxWindow* parent, wxString m)
{
- auto d = make_wx<wxMessageDialog>(parent, m, _("DCP-o-matic"), wxYES_NO | wxICON_QUESTION);
+ auto d = make_wx<wxMessageDialog>(parent, m, variant::wx::dcpomatic(), wxYES_NO | wxICON_QUESTION);
return d->ShowModal() == wxID_YES;
}
}
+#ifdef DCPOMATIC_OSX
+
+void
+dcpomatic_setup_i18n()
+{
+ wxLog::EnableLogging();
+
+ 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(wxT("build/src/wx/mo"));
+ wxFileTranslationsLoader::AddCatalogLookupPathPrefix(wxT("build/src/tools/mo"));
+#endif
+
+ translations->AddStdCatalog();
+ translations->AddCatalog(wxT("libdcpomatic2-wx"));
+ translations->AddCatalog(wxT("dcpomatic2"));
+
+ wxTranslations::Set(translations);
+
+ dcpomatic_setup_gettext_i18n(config_lang.get_value_or(""));
+}
+
+#else
+
void
dcpomatic_setup_i18n ()
{
}
}
+#endif
+
int
wx_get (wxSpinCtrl* w)
wxSplashScreen*
maybe_show_splash ()
{
+ if (!variant::show_splash()) {
+ return nullptr;
+ }
+
wxSplashScreen* splash = nullptr;
try {
int
get_offsets (vector<Offset>& offsets)
{
- offsets.push_back (Offset(_("UTC-11"), -11, 0));
- offsets.push_back (Offset(_("UTC-10"), -10, 0));
- offsets.push_back (Offset(_("UTC-9"), -9, 0));
- offsets.push_back (Offset(_("UTC-8"), -8, 0));
- offsets.push_back (Offset(_("UTC-7"), -7, 0));
- offsets.push_back (Offset(_("UTC-6"), -6, 0));
- offsets.push_back (Offset(_("UTC-5"), -5, 0));
- offsets.push_back (Offset(_("UTC-4:30"), -4, 30));
- offsets.push_back (Offset(_("UTC-4"), -4, 0));
- offsets.push_back (Offset(_("UTC-3:30"), -3, 30));
- offsets.push_back (Offset(_("UTC-3"), -3, 0));
- offsets.push_back (Offset(_("UTC-2"), -2, 0));
- offsets.push_back (Offset(_("UTC-1"), -1, 0));
+ offsets.push_back({_("UTC-11"), dcp::UTCOffset(-11, 0)});
+ offsets.push_back({_("UTC-10"), dcp::UTCOffset(-10, 0)});
+ offsets.push_back({_("UTC-9"), dcp::UTCOffset( -9, 0)});
+ offsets.push_back({_("UTC-8"), dcp::UTCOffset( -8, 0)});
+ offsets.push_back({_("UTC-7"), dcp::UTCOffset( -7, 0)});
+ offsets.push_back({_("UTC-6"), dcp::UTCOffset( -6, 0)});
+ offsets.push_back({_("UTC-5"), dcp::UTCOffset( -5, 0)});
+ offsets.push_back({_("UTC-4:30"),dcp::UTCOffset( -4, -30)});
+ offsets.push_back({_("UTC-4"), dcp::UTCOffset( -4, 0)});
+ offsets.push_back({_("UTC-3:30"),dcp::UTCOffset( -3, -30)});
+ offsets.push_back({_("UTC-3"), dcp::UTCOffset( -3, 0)});
+ offsets.push_back({_("UTC-2"), dcp::UTCOffset( -2, 0)});
+ offsets.push_back({_("UTC-1"), dcp::UTCOffset( -1, 0)});
int utc = offsets.size();
- offsets.push_back (Offset(_("UTC") , 0, 0));
- offsets.push_back (Offset(_("UTC+1"), 1, 0));
- offsets.push_back (Offset(_("UTC+2"), 2, 0));
- offsets.push_back (Offset(_("UTC+3"), 3, 0));
- offsets.push_back (Offset(_("UTC+4"), 4, 0));
- offsets.push_back (Offset(_("UTC+5"), 5, 0));
- offsets.push_back (Offset(_("UTC+5:30"), 5, 30));
- offsets.push_back (Offset(_("UTC+6"), 6, 0));
- offsets.push_back (Offset(_("UTC+7"), 7, 0));
- offsets.push_back (Offset(_("UTC+8"), 8, 0));
- offsets.push_back (Offset(_("UTC+9"), 9, 0));
- offsets.push_back (Offset(_("UTC+9:30"), 9, 30));
- offsets.push_back (Offset(_("UTC+10"), 10, 0));
- offsets.push_back (Offset(_("UTC+11"), 11, 0));
- offsets.push_back (Offset(_("UTC+12"), 12, 0));
+ offsets.push_back({_("UTC") , dcp::UTCOffset( 0, 0)});
+ offsets.push_back({_("UTC+1"), dcp::UTCOffset( 1, 0)});
+ offsets.push_back({_("UTC+2"), dcp::UTCOffset( 2, 0)});
+ offsets.push_back({_("UTC+3"), dcp::UTCOffset( 3, 0)});
+ offsets.push_back({_("UTC+4"), dcp::UTCOffset( 4, 0)});
+ offsets.push_back({_("UTC+5"), dcp::UTCOffset( 5, 0)});
+ offsets.push_back({_("UTC+5:30"),dcp::UTCOffset( 5, 30)});
+ offsets.push_back({_("UTC+6"), dcp::UTCOffset( 6, 0)});
+ offsets.push_back({_("UTC+7"), dcp::UTCOffset( 7, 0)});
+ offsets.push_back({_("UTC+8"), dcp::UTCOffset( 8, 0)});
+ offsets.push_back({_("UTC+9"), dcp::UTCOffset( 9, 0)});
+ offsets.push_back({_("UTC+9:30"),dcp::UTCOffset( 9, 30)});
+ offsets.push_back({_("UTC+10"), dcp::UTCOffset( 10, 0)});
+ offsets.push_back({_("UTC+11"), dcp::UTCOffset( 11, 0)});
+ offsets.push_back({_("UTC+12"), dcp::UTCOffset( 12, 0)});
return utc;
}