List available languages for PyGTK UI strings

Posted by detly on Stack Overflow See other posts from Stack Overflow or by detly
Published on 2010-05-23T09:42:43Z Indexed on 2010/05/23 9:50 UTC
Read the original article Hit count: 299

Filed under:
|
|
|

I'm cleaning up some localisation and translation settings in our PyGTK application. The app is only intended to be used under GNU/Linux systems. One of the features we want is for users to select the language used for the applications (some prefer their native language, some prefer English for consistency, some like French because it sounds romantic, etc).

For this to work, I need to actually show a combo box with the various languages available. How can I get this list? In fact, I need a list of pairs of the language code ("en", "ru", etc) and the language name in the native language ("English (US)", "???????").

If I had to implement a brute force method, I'd do something like: look in the system locale dir (eg. "/usr/share/locale") for all language code dirs (eg. "en/") containing the relative path "LC_MESSAGES/OurAppName.mo".

Is there a more programmatic way?

© Stack Overflow or respective owner

Related posts about python

Related posts about translation