Set gtk language based on selected language in RT, fixes #4278, kudos to @agriggio
This commit is contained in:
@@ -94,10 +94,34 @@ struct LocaleToLang : private std::map<std::pair<Glib::ustring, Glib::ustring>,
|
|||||||
|
|
||||||
return "default";
|
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;
|
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;
|
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();
|
translations.clear();
|
||||||
|
|
||||||
for (const auto& fname : fnames) {
|
for (const auto& fname : fnames) {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class MultiLangMgr
|
|||||||
public:
|
public:
|
||||||
MultiLangMgr ();
|
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;
|
Glib::ustring getStr(const std::string& key) const;
|
||||||
static bool isOSLanguageDetectSupported();
|
static bool isOSLanguageDetectSupported();
|
||||||
static Glib::ustring getOSUserLanguage();
|
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);
|
rtengine::init (&options.rtSettings, argv0, rtdir, !lightweight);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user