Document how to translate third-party extensions
After some investigation, I found an easy way to translate external extensions (in particular, translate external extension inx files). It would be great to document this process for external extension authors, and to make it easy for people packaging it via the extension manager to do so too.
If we put a translationdomain="my_extension" attribute (ideally something unique so that nothing will conflict as it will be looked for as a filename later) at the root element of the inx, this codepath will look at the following places for translation files :
/* For this the following three locations are recursively searched for "${translationdomain}.mo":
* - the 'locale' directory in the .inx file's folder
* - the 'locale' directory in the "extensions" folder containing the .inx
* - the system location for gettext catalogs, i.e. where Inkscape's own catalog is located
*
* If one matching file is found, the directory is assumed to be the correct location and registered with gettext */
So, if you take the inx.its file from the Inkscape main repo, you are able to run xgettext my_extension.inx --its=inx.its -o my_extension.pot
. Then you can distribute this pot file to translators, and get files for various languages.
Then you can keep those po files and store them in a repo, you will only need the .mo files generated from those, in a special structure:
locale/
├── ar
│ └── LC_MESSAGES
│ └── my_extension.mo
├── as
│ └── LC_MESSAGES
│ └── my_extension.mo
├── az
│ └── LC_MESSAGES
│ └── my_extension.mo
├── be
│ └── LC_MESSAGES
│ └── my_extension.mo
...
If those files are, for instance, in .config/inkscape/extensions/locale/<lang>/LC_MESSAGES/my_extension.mo
, then an inx file at .config/inkscape/extensions/my_extension.inx
with the right translationdomain
will be translated in the interface.
(caveat : for now the name is not translated, I will do a MR against inkscape/inkscape later to fix that)