aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJohannes Schickel2010-06-15 17:47:23 +0000
committerJohannes Schickel2010-06-15 17:47:23 +0000
commitd8bc79814532818615a571e327e9f4d201e93057 (patch)
tree28c3accb7c58283a80a23aadef805449cbdbaa2a /common
parentf3288b0f267672a6f9b0039cf9aeff514d2e42f8 (diff)
downloadscummvm-rg350-d8bc79814532818615a571e327e9f4d201e93057.tar.gz
scummvm-rg350-d8bc79814532818615a571e327e9f4d201e93057.tar.bz2
scummvm-rg350-d8bc79814532818615a571e327e9f4d201e93057.zip
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
Diffstat (limited to 'common')
-rw-r--r--common/translation.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/common/translation.cpp b/common/translation.cpp
index d29e7b5c72..c7bcb385d1 100644
--- a/common/translation.cpp
+++ b/common/translation.cpp
@@ -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