# HG changeset patch # User tron # Date 1157097971 0 # Node ID fb99bcd74dd5ebbdd71b254417c4e5a7c3cd3252 # Parent 4edafcdcd4a4c57264434b9d973b4887e8e5fd20 (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 diff --git a/strings.c b/strings.c --- 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");