Strip out charset information from the system locale again (like it was done before r49871).

Unlike with the old code, we know allow for locales
with a different size than 5 though.

svn-id: r49876
This commit is contained in:
Johannes Schickel 2010-06-15 17:47:23 +00:00
parent f3288b0f26
commit d8bc798145

View file

@ -52,10 +52,28 @@ TranslationManager::TranslationManager() {
const char *locale = setlocale(LC_ALL, "");
// Detect the language from the locale
if (!locale)
if (!locale) {
_syslang = "C";
else
_syslang = locale;
} else {
int length = 0;
// Strip out additional information, like
// ".UTF-8" or the like. We do this, since
// our translation languages are usually
// specified without any charset information.
for (int i = 0; locale[i]; ++i) {
// TODO: Check whether "@" should really be checked
// here.
if (locale[i] == '.' || locale[i] == ' ' || locale[i] == '@') {
length = i;
break;
}
length = i;
}
_syslang = String(locale, length);
}
#else // DETECTLANG
_syslang = "C";
#endif // DETECTLANG