summaryrefslogtreecommitdiff
path: root/i18n.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2007-08-17 12:38:55 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2007-08-17 12:38:55 +0200
commit7bb744ccb03c9c5685e66c2db4fab62d7d3ec7f1 (patch)
treeab2f39ae2454f73d526c7cbfa67c64be530535f6 /i18n.c
parent00328c31e13f2a4ecf10251f8992ec45d19500bd (diff)
downloadvdr-7bb744ccb03c9c5685e66c2db4fab62d7d3ec7f1.tar.gz
vdr-7bb744ccb03c9c5685e66c2db4fab62d7d3ec7f1.tar.bz2
I18nInitialize() now uses best matching default locale
Diffstat (limited to 'i18n.c')
-rw-r--r--i18n.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/i18n.c b/i18n.c
index 7bd27806..664b8113 100644
--- a/i18n.c
+++ b/i18n.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: i18n.c 1.309 2007/08/15 14:17:56 kls Exp $
+ * $Id: i18n.c 1.310 2007/08/17 12:31:17 kls Exp $
*
*
*/
@@ -100,12 +100,15 @@ void I18nInitialize(void)
cFileNameList Locales(I18nLocaleDir, true);
if (Locales.Size() > 0) {
dsyslog("found %d locales in %s", Locales.Size(), I18nLocaleDir);
+ int MatchFull = 0, MatchPartial = 0;
char *OldLocale = strdup(setlocale(LC_MESSAGES, NULL));
for (int i = 0; i < Locales.Size(); i++) {
if (i < I18N_MAX_LANGUAGES - 1) {
if (setlocale(LC_MESSAGES, Locales[i])) {
if (strstr(OldLocale, Locales[i]) == OldLocale)
- CurrentLanguage = LanguageLocales.Size();
+ MatchFull = LanguageLocales.Size();
+ else if (strncmp(OldLocale, Locales[i], 2) == 0)
+ MatchPartial = LanguageLocales.Size();
LanguageLocales.Append(strdup(Locales[i]));
LanguageNames.Append(strdup(gettext(LanguageName)));
const char *Code = gettext(LanguageCode);
@@ -121,7 +124,8 @@ void I18nInitialize(void)
else
esyslog("ERROR: too many locales - increase I18N_MAX_LANGUAGES!");
}
- setlocale(LC_MESSAGES, OldLocale);
+ CurrentLanguage = MatchFull ? MatchFull : MatchPartial;
+ setlocale(LC_MESSAGES, CurrentLanguage ? LanguageLocales[CurrentLanguage] : OldLocale);
free(OldLocale);
}
// Prepare any known language codes for which there was no locale: