- if (Translation.compare("environment") == 0)
- return std::setlocale(LC_ALL,NULL);
+ if (Translation.compare("environment") == 0)
+ {
+ string lang = std::setlocale(LC_MESSAGES,NULL);
+
+ // we have a mapping of the language codes that contains all the language
+ // codes that need the country code as well
+ // (like pt_BR, pt_PT, sv_SE, zh_*, en_*)
+ const char *need_full_langcode[] = { "cs_",
+ "en_",
+ "pt_",
+ "sv_",
+ "zh_",
+ NULL };
+ for(const char **s = need_full_langcode;*s != NULL; s++)
+ if(lang.find(*s) == 0)
+ return lang.substr(0,5);
+
+ if(lang.find("_") != lang.npos)
+ return lang.substr(0, lang.find("_"));
+ else
+ return lang;
+ }