On Samstag, 18. August 2007, Klaus Schmidinger wrote:
On 08/18/07 13:10, Matthias Schwarzott wrote:
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?
First: general directory layout: /usr/share/locale/*/LC_MESSAGES/*.mo contains translations
the oposite is /usr/lib/locale. This does NOT contain translations (and if you insisit on the difference: nowhere in the subdirs are translations). There are just descriptions of the available locales.
You now do this: Loop over the subdirs of vdr-private-locale directory and then check which of these are actually available by doing setlocale.
Now this can also be done by a check if there is some matching directory under /usr/lib/locale/.
Regarding the english name of the associated language: locale -a -v will not only print the list of locales, but also a lot of detail info. This info should also be available via some API. But searching did not produce any API to query this.
Some cut out example: # locale -a -v ... locale: de_DE.utf8 directory: /usr/lib/locale/de_DE.utf8 ------------------------------------------------------------------------------- title | German locale for Germany source | Free Software Foundation, Inc. address | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA email | bug-glibc-locales@gnu.org language | German territory | Germany revision | 1.0 date | 2000-06-24 codeset | UTF-8
locale: en_GB directory: /usr/lib/locale/en_GB ------------------------------------------------------------------------------- title | English locale for Britain source | RAP address | Sankt J�rgens Alle 8, DK-1615 K�benhavn V, Danmark contact | Keld Simonsen email | bug-glibc-locales@gnu.org language | English territory | Great Britain revision | 1.0 date | 2000-06-28 codeset | ISO-8859-1 ...
Matthias