aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
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