Fixed C++-sent progress messages not translated.

It seems that separate threads use separate 'global' locales.
This commit is contained in:
Oliver Hamlet
2015-01-08 21:03:57 +00:00
parent 21a643daa0
commit 984646e1fa
+15
View File
@@ -105,6 +105,21 @@ namespace loot {
// Specify CEF browser settings here.
CefBrowserSettings browser_settings;
// Need to set the global locale for this process so that messages will
// be translated.
BOOST_LOG_TRIVIAL(debug) << "Initialising language settings in UI thread.";
const YAML::Node& settings = g_app_state.GetSettings();
if (settings["language"] && settings["language"].as<string>() != Language(Language::english).Locale()) {
boost::locale::generator gen;
gen.add_messages_path(g_path_l10n.string());
gen.add_messages_domain("loot");
loot::Language lang(settings["language"].as<string>());
BOOST_LOG_TRIVIAL(debug) << "Selected language: " << lang.Name();
locale::global(gen(lang.Locale() + ".UTF-8"));
boost::filesystem::path::imbue(locale());
}
// Set URL to load. Ignore any command line values.
std::string url = ToFileURL(g_path_report);