Mercurial > hg > openttd
changeset 4505:fb99bcd74dd5 draft
(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
author | tron <tron@openttd.org> |
---|---|
date | Fri, 01 Sep 2006 08:06:11 +0000 |
parents | 4edafcdcd4a4 |
children | f520272e5d80 |
files | strings.c |
diffstat | 1 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/strings.c +++ b/strings.c @@ -1217,18 +1217,20 @@ 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 @@ 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");