summaryrefslogtreecommitdiff
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
parent00328c31e13f2a4ecf10251f8992ec45d19500bd (diff)
downloadvdr-7bb744ccb03c9c5685e66c2db4fab62d7d3ec7f1.tar.gz
vdr-7bb744ccb03c9c5685e66c2db4fab62d7d3ec7f1.tar.bz2
I18nInitialize() now uses best matching default locale
-rw-r--r--CONTRIBUTORS1
-rw-r--r--HISTORY2
-rw-r--r--i18n.c10
3 files changed, 10 insertions, 3 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index f21eba17..483dd583 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -2092,6 +2092,7 @@ Matthias Schwarzott <zzam@gentoo.org>
for suggesting to move the "all" target in plugin Makefiles before the
"Implicit rules", so that a plain "make" will compile everything
for adding DESTDIR and PREFIX handling to the Makefile
+ for reporting a problem with locale matching
Martin Ostermann <martin@familie-ostermann.de>
for fixing processing the PDCDescriptor in 'libsi' on big endian systems
diff --git a/HISTORY b/HISTORY
index 7a5be9a3..0e8ba59b 100644
--- a/HISTORY
+++ b/HISTORY
@@ -5363,3 +5363,5 @@ Video Disk Recorder Revision History
Ahrenberg).
- Checking the string for NULL in I18nTranslate().
- Updated the French OSD texts (thanks to Bruno Roussel).
+- I18nInitialize() now uses best matching default locale (problem reported by
+ Matthias Schwarzott).
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: