[vdr] improving i18n-to-gettext.pl

Anssi Hannula anssi.hannula at gmail.com
Sat Aug 18 13:46:59 CEST 2007


Klaus Schmidinger wrote:
> On 08/18/07 13:10, Matthias Schwarzott wrote:
>> On Samstag, 18. August 2007, Klaus Schmidinger wrote:
>>> On 08/18/07 12:55, Matthias Schwarzott wrote:
>>>> On Freitag, 17. August 2007, Klaus Schmidinger wrote:
>>>>> On 08/15/07 15:07, Matthias Schwarzott wrote:
>>>>>> On Mittwoch, 15. August 2007, Klaus Schmidinger wrote:
>>>>>>
>>>>>> 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.
>>>> Not yet tested, but code looks promising.
>>>>
>>>> Another way to get list of usable locales is this:
>>>> Checking the subdirs of /usr/lib/locale/
>>>> And then using all, that have associated mo file under vdr's LOCALEDIR.
>>>> Sadly I don't know if there is a better way than hardcoding that
>>>> directory.
>>>>
>>>> But "locale -a" command will give the same result - maybe analyzing its
>>>> code will help (or just calling this external command).
>>> Currently VDR has its own directory with all its supported locales.
>>> It can quickly collect all locales by going through the entries
>>> in that directory. I can even compile my VDR so that it searches
>>> for the locales in "./locale" inside the source directory.
>>>
>>> I like the simplicity of this, and wouldn't want to make it any
>>> more complex.
>>>
>> The directory /usr/lib/locale does NOT contain any translations, but rather a 
>> directory for every locale you can set via setlocale.
>> Its meant as a replacement of the setlocale loop.
> 
> I'm afraid I don't see what you mean.
> I know that the "locale" directory doesn't contain translations directly,
> but rather subdirectories. VDR gathers the names of these subdirectories
> and does a setlocale() for each of them. Then it tries to get the
> translation of "LanguageName$English" in order to build a list of all
> available languages. How else do you suggest that could be done?

I think he meant to traverse the system locales directory to gather the 
list of potentially valid locales that can be used to call setlocale().

The VDR locale directory names may or may not be valid locale names on 
the running system.

This is what AFAICS "locale -a" uses (glibc/locale/programs/locale.c). 
It also checks the existence of the locale identification file and 
parses locale aliases from locale.alias.


-- 
Anssi Hannula



More information about the vdr mailing list