mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
I18nInitialize() now uses best matching default locale
This commit is contained in:
parent
00328c31e1
commit
7bb744ccb0
@ -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
|
||||
|
2
HISTORY
2
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).
|
||||
|
10
i18n.c
10
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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user