What should an application developed under a Linux System like Ubuntu do so as to automatically detect the system language? There are applications, like Liferea that automatically change their language to match the system's, without altering any preference of the program itself:
Should this be the "default" behavior for all the programs?Should there be an option on the program so as to let the user choose the language nonetheless?
Are all these translations coming along with the program itself? What if the user has set a system language not available in the translations of the program?
Is this Ubuntu or most-linux-distros specific?
|
|
|||
|
|
|
I know that application development with Quickly and Launchpad support Translations to do this. I'm no expert so check out these links in addition to my answer: http://www.gnu.org/software/gettext/ https://help.launchpad.net/Translations My application imports the gettext module which then allows me to mark strings that will be displayed to the user in the program. When my program is submitted to Launchpad via Quickly, Launchpad is set up to automatically scan through the source code and generate special translation template files for the marked strings. Kind Launchpad users (or the developer), can then use the template to generate translations for each string and language they'd like. These translation files can then be sync'd to your source branch and merged before release. On runtime the gettext module then replaces marked strings with the appropriate translation based on your system locale. To summarize, here's a list of the process:
Here's the header of my program where I import gettext through locale (note that Quickly adds all this for me! locale and bindtextdomain are added because it's being put in /opt/extras.ubuntu.com I think):
Now I just mark text to be translated with |
|||
|
|
|
In the future, even if they are related, I'd suggest opening separate questions for each. In any case, I'll have a go at answering them:
You simply need to initialize In the most basic case, and using Python
Notes:
Yes.
No. If you want to have such an option, you're on your own and will have to implement it yourself. The convention is that there is only one per-user language and you change that only in one place, affecting all apps in the system.
Yes, they are shipped along with the app as binary
Then the default for gettext is to use English as a fallback.
This is the standard behaviour for Linux distros. |
||||
|
|