firstly, the path to the .mo files was wrong (the code assumed that
OSX was like Linux). Secondly, the string passed into putenv() must
not be freed by the caller (as its docs say). It appears that you
get away with not doing this on Linux and Windows.
2014-08-31 Carl Hetherington <cth@carlh.net>
2014-08-31 Carl Hetherington <cth@carlh.net>
+ * Fix lack of i18n of strings from src/lib/po on OS X.
+
* Give a hint when content and container aspect ratios are not
the same (#392).
* Give a hint when content and container aspect ratios are not
the same (#392).
+#ifdef DCPOMATIC_OSX
+boost::filesystem::path
+mo_path ()
+{
+ return "DCP-o-matic.app/Contents/Resources";
+}
+#endif
+
void
dcpomatic_setup_gettext_i18n (string lang)
{
void
dcpomatic_setup_gettext_i18n (string lang)
{
lang += ".UTF8";
#endif
if (!lang.empty ()) {
lang += ".UTF8";
#endif
if (!lang.empty ()) {
- /* Override our environment language; this is essential on
- Windows.
+ /* Override our environment language. Note that the caller must not
+ free the string passed into putenv().
- char cmd[64];
- snprintf (cmd, sizeof(cmd), "LANGUAGE=%s", lang.c_str ());
- putenv (cmd);
- snprintf (cmd, sizeof(cmd), "LANG=%s", lang.c_str ());
- putenv (cmd);
- snprintf (cmd, sizeof(cmd), "LC_ALL=%s", lang.c_str ());
- putenv (cmd);
+ string s = String::compose ("LANGUAGE=%1", lang);
+ putenv (strdup (s.c_str ()));
+ s = String::compose ("LANG=%1", lang);
+ putenv (strdup (s.c_str ()));
+ s = String::compose ("LC_ALL=%1", lang);
+ putenv (strdup (s.c_str ()));
}
setlocale (LC_ALL, "");
textdomain ("libdcpomatic");
}
setlocale (LC_ALL, "");
textdomain ("libdcpomatic");
-#ifdef DCPOMATIC_WINDOWS
+#if defined(DCPOMATIC_WINDOWS) || defined(DCPOMATIC_OSX)
bindtextdomain ("libdcpomatic", mo_path().string().c_str());
bind_textdomain_codeset ("libdcpomatic", "UTF8");
#endif
bindtextdomain ("libdcpomatic", mo_path().string().c_str());
bind_textdomain_codeset ("libdcpomatic", "UTF8");
#endif
bindtextdomain ("libdcpomatic", POSIX_LOCALE_PREFIX);
#endif
}
bindtextdomain ("libdcpomatic", POSIX_LOCALE_PREFIX);
#endif
}