summaryrefslogtreecommitdiff
path: root/strings.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-09-01 08:06:11 +0000
committertron <tron@openttd.org>2006-09-01 08:06:11 +0000
commit7d3685a8ad0661c43dda4deb8c2559226b3370fe (patch)
tree6b52ef4301ab1bed54733763e38955ef107006f3 /strings.c
parentc05c81f35c70a95d4d528bdbc8da391b244da065 (diff)
downloadopenttd-7d3685a8ad0661c43dda4deb8c2559226b3370fe.tar.xz
(svn r6290) -Feature: When automatically detecting the language try to first match language+territory (e.g. de_CH), then just language (e.g. de) and fall back to en_GB otherwise
Diffstat (limited to 'strings.c')
-rw-r--r--strings.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/strings.c b/strings.c
index fab1628b5..8436dfcd4 100644
--- a/strings.c
+++ b/strings.c
@@ -1217,18 +1217,20 @@ void InitializeLanguagePacks(void)
int n;
int m;
int def;
+ int def2;
int fallback;
LanguagePack hdr;
FILE *in;
char *files[32];
+ const char* lang;
- char lang[] = "en";
- const char *env = GetCurrentLocale("LC_MESSAGES");
+ lang = GetCurrentLocale("LC_MESSAGES");
+ if (lang == NULL) lang = "en_GB";
- if (env != NULL) snprintf(lang, lengthof(lang), "%.2s", env);
n = GetLanguageList(files, lengthof(files));
def = -1;
+ def2 = -1;
fallback = 0;
// go through the language files and make sure that they are valid.
@@ -1249,12 +1251,13 @@ void InitializeLanguagePacks(void)
dl->ent[m].file = files[i];
dl->ent[m].name = strdup(hdr.name);
- if (strcmp(hdr.name, "English") == 0) fallback = m;
- if (strncmp(hdr.isocode, lang, 2) == 0) def = m;
+ if (strcmp(hdr.isocode, "en_GB") == 0) fallback = m;
+ if (strncmp(hdr.isocode, lang, 2) == 0) def2 = m;
+ if (strncmp(hdr.isocode, lang, 5) == 0) def = m;
m++;
}
- if (def == -1) def = fallback;
+ if (def == -1) def = (def2 != -1 ? def2 : fallback);
if (m == 0)
error(n == 0 ? "No available language packs" : "Invalid version of language packs");