On 08/15/07 15:07, Matthias Schwarzott wrote:
> On Mittwoch, 15. August 2007, Klaus Schmidinger wrote:
>> On 08/15/07 14:02, Matthias Schwarzott wrote:
>>> On Mittwoch, 15. August 2007, Matthias Fechner wrote:
>>>> Hi Matthias,
>>>>
>>>>
>>>> because German is spoken in more then one country: de_DE, de_AT and I
>>>> think de_CH and more. I havn't not list with all locales here now.
>>> Yeah, german is spoken in other countries. Is there then a reason to
>>> restrict the translation to germany?
>>>
>>> some example:
>>> wget installs the file /usr/share/locale/de/LC_MESSAGES/wget.mo
>>> this is to provide translations for "all" de* locales. Not just the
>>> german one, but also for austria and swiss.
>> I just tried renaming VDR's "de_DE" locale to "de" and did
>>
>> LC_ALL=de_AT ./vdr
>>
> This will work, but only if the locale de_AT you set does exist (being in 
> output of locale -a).
>> but it came up with the default English texts. Then I renamed
>> "de" to "de_AT" and did the same again, and I got the German texts.
>>
>> I was hoping that gettext would be a little more intelligent and
>> look for
>>
>> - an exact match ("de_AT")
>> - a default ("de")
>> - any suitable language ("de_DE")
> 
> I think it does this but not doing "any suitable language".
> ...

Could you please try the attached patch and see whether this
works for you?

This should, e.g., select any "de*" locale in case there is no fully
matching one.

Klaus
--- i18n.c	2007/08/15 14:17:56	1.309
+++ i18n.c	2007/08/17 12:31:17
@@ -100,12 +100,15 @@
   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 @@
          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:
_______________________________________________
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

Reply via email to