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:
parent
f3288b0f26
commit
d8bc798145
1 changed files with 21 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue