mirror of
https://github.com/anope/anope.git
synced 2026-06-29 19:56:37 +02:00
Made the language system still work even if the locales are not installed on the system
This commit is contained in:
+5
-2
@@ -54,9 +54,12 @@ const Anope::string GetString(Anope::string language, LanguageString string)
|
||||
return language_strings[string];
|
||||
|
||||
#if GETTEXT_FOUND
|
||||
setlocale(LC_ALL, language.c_str());
|
||||
extern int _nl_msg_cat_cntr;
|
||||
++_nl_msg_cat_cntr;
|
||||
setenv("LANGUAGE", language.c_str(), 1);
|
||||
setlocale(LC_ALL, "en_US");
|
||||
const char *ret = dgettext("anope", language_strings[string].c_str());
|
||||
setlocale(LC_ALL, "");
|
||||
unsetenv("LANGUAGE");
|
||||
|
||||
return ret ? ret : "";
|
||||
#endif
|
||||
|
||||
+5
-2
@@ -299,9 +299,12 @@ void Module::SendMessage(BotInfo *from, User *to, const char *fmt, ...)
|
||||
#if GETTEXT_FOUND
|
||||
if (!language.empty())
|
||||
{
|
||||
setlocale(LC_ALL, language.c_str());
|
||||
extern int _nl_msg_cat_cntr;
|
||||
++_nl_msg_cat_cntr;
|
||||
setenv("LANGUAGE", language.c_str(), 1);
|
||||
setlocale(LC_ALL, "en_US");
|
||||
message = dgettext(this->name.c_str(), fmt);
|
||||
setlocale(LC_ALL, "");
|
||||
unsetenv("LANGUAGE");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user