multi-language in the INX file ?

Asked by emlaurent on 2012-07-30

Hi,
I would like to have a multi-language interface inside an inkscape extension.
I would like that the user could choose the language and then all the _gui-text parameters
will change to the corresponding text. I do not want an automatic transation but I would like to
give myself the text.
How could I do that in the INX file ?
thanks
Emmanuel

Question information

Language:
English Edit question
Status:
Solved
For:
Inkscape Edit question
Assignee:
No assignee Edit question
Solved by:
jazzynico
Solved:
2012-08-03
Last query:
2012-08-03
Last reply:
2012-07-30
jazzynico (jazzynico) said : #1

Hi Emmanuel,

All the Inkscape strings are currently translated in a global PO files, and the application language is set depending on the user's preferences. Thus it's not possible to have Inkscape in a language and an extension in an other one.
Anyway, it's possible to add your strings to your translation file, but it requires some tricky steps, and requires that you release your extension with the language files for all the translations you plan to add (can be heavy) with your extension.
Anyway, I can help you if you tell me your operating system and Inkscape version.

Regards.

emlaurent (laurent-em) said : #2

Hi JazzyNico

Thanks for the answer!
In fact, no function to propose an extension interface in the language specified in the preferences...
I do not want to modify the PO file because the extension will be proposed to everybody and it will not easy to use !

Another solution is to write several files
name_of_extension-fr.inx,
name_of_extension-en.inx,
name_of_extension-de.inx

one file per language and the user could choose to install the right file

Another question : is there any python function which gives the language in the inkscape preferences ?

thanks
emmanuel

Best jazzynico (jazzynico) said : #3

> one file per language and the user could choose to install the right file

Yes, probably the easiest solution.

> is there any python function which gives the language in the inkscape preferences ?

I think you can't. The python extension doesn't communicate that much with the application. It receives the values of the options from the INX file, and, when necessary, the current document. Thus it can't get the language directly from Inkscape. Instead, it might be possible to analyze the preferences.xml file, but you have to guess its location.
It's also possible to get the operating system language from the LANG variable, but on Windows, it's not (yet, I have a patch in progress for 0.49) set automatically.
Then, you can use gettext with Python to use the PO file of your choice, directly from a subdirectory in the user's extension directory.

Don't hesitate to post your files and questions on the LinuxGraphic forum if you need further help in French (http://linuxgraphic.org/forums/viewforum.php?f=6) , or on Inkscape forum in English (http://www.inkscapeforum.com/ ).

Regards.

emlaurent (laurent-em) said : #4

Thanks JazzyNico, that solved my question.