Set gtk language based on selected language in RT, fixes #4278, kudos to @agriggio
This commit is contained in:
parent
857f39eb88
commit
309eef696b
@ -94,10 +94,34 @@ struct LocaleToLang : private std::map<std::pair<Glib::ustring, Glib::ustring>,
|
||||
|
||||
return "default";
|
||||
}
|
||||
|
||||
std::string getLocale(const Glib::ustring &language) const
|
||||
{
|
||||
for (auto &p : *this) {
|
||||
if (p.second == language) {
|
||||
std::string ret = p.first.first;
|
||||
if (!p.first.second.empty()) {
|
||||
ret += "_" + p.first.second;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return "C";
|
||||
}
|
||||
};
|
||||
|
||||
const LocaleToLang localeToLang;
|
||||
|
||||
void setGtkLanguage(const Glib::ustring &language)
|
||||
{
|
||||
auto l = localeToLang.getLocale(language);
|
||||
#ifdef WIN32
|
||||
putenv(("LANG=" + l).c_str());
|
||||
#else
|
||||
setenv("LANG", l.c_str(), true);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MultiLangMgr langMgr;
|
||||
@ -106,8 +130,10 @@ MultiLangMgr::MultiLangMgr ()
|
||||
{
|
||||
}
|
||||
|
||||
void MultiLangMgr::load (const std::vector<Glib::ustring> &fnames)
|
||||
void MultiLangMgr::load(const Glib::ustring &language, const std::vector<Glib::ustring> &fnames)
|
||||
{
|
||||
setGtkLanguage(language);
|
||||
|
||||
translations.clear();
|
||||
|
||||
for (const auto& fname : fnames) {
|
||||
|
@ -30,7 +30,7 @@ class MultiLangMgr
|
||||
public:
|
||||
MultiLangMgr ();
|
||||
|
||||
void load(const std::vector<Glib::ustring> &fnames);
|
||||
void load(const Glib::ustring &language, const std::vector<Glib::ustring> &fnames);
|
||||
Glib::ustring getStr(const std::string& key) const;
|
||||
static bool isOSLanguageDetectSupported();
|
||||
static Glib::ustring getOSUserLanguage();
|
||||
|
@ -2323,7 +2323,7 @@ void Options::load (bool lightweight)
|
||||
}
|
||||
}
|
||||
|
||||
langMgr.load ({localeTranslation, languageTranslation, defaultTranslation});
|
||||
langMgr.load (options.language, {localeTranslation, languageTranslation, defaultTranslation});
|
||||
|
||||
rtengine::init (&options.rtSettings, argv0, rtdir, !lightweight);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user