Make gedit-file-search translatable
jpfleury opened this issue · 12 comments
I would like to help making this plugin translatable. I'll try to provide patches.
First patch: Translation in French of "file-search.gedit-plugin
About file-search.glade
About file-search.glade
, strings are already flagged as translatable with translatable
attribute. Example:
<property name="label" translatable="yes">Only these file types:</property>
but we must extract these strings to create a template. The new target make pot
in the Makefile achieves this, by generating the file file-search.pot
in the new folder file-search-lang
.
Then, to make a translation, we just have to create a .po
file by copying this template and paste it in file-search-lang/LANG/LC_MESSAGES/file-search.po
(replace LANG
with the lang code), for example:
file-search-lang/fr/LC_MESSAGES/file-search.po
If the template was changed, .po
files can be updated with the target make po
.
To make a translation usable in gedit, each .po
file must be compiled into a .mo
binary file. The new target make mo
is used for this.
All these steps can be performed with the single target make tgz
, that depends on both po
and mo
targets.
The following patch adds all needed stuff in Makefile
:
gedit-file-search: patch to make Makefile manage translation
The following file is the translation in French (so the file file-search-lang/fr/LC_MESSAGES/file-search.po
):
gedit-file-search: translation in French
To ignore .mo
binary files with git, apply this patch:
gedit-file-search: patch to ignore .mo
binary files with git
About file-search.py
The last modifications needed are about file-search.py
:
- This file must call gettext, so translations can be used.
- Also, a few strings are not flagged as translatable. Translatable strings must be a parameter of function
_()
, for example_("Expand All")
. Note: the targetmake pot
already adds to the template all translatable strings found infile-search.py
. - Plural is hardcoded, but plural forms differ from a language to another. For example, in French, singular is used for zero and one. Example: 0 occurrence trouvée (in English: 0 matches found). So plural forms must be managed by gettext.
The following patch solves these 3 points:
Wow, nice work - thanks a lot!
It would be good if we could get this integrated on the new "subdir" branch (https://github.com/oliver/gedit-file-search/tree/subdir) which already puts all files into a new subdirectory. I'll see to get the subdir stuff finished and will then merge the translation code.
OK. Surely patches will need some adjustments. Say me when I can use https://github.com/oliver/gedit-file-search/tree/subdir to modify them.
In the meantime, I'll modify a little bit my patch for file-search.py
, because it interferes with gedit translation.
Problem solved. The patch has been updated.
The subdir branch has been merged into master branch now, so you can do any adjustments based on master.
Cool. I test my patches right now.
Sorry, I had forgotten to adjust the Makefile for the subdirectory move. It's updated now - can you take that into account yet?
No problem.
All patches have been updated:
- for
file-search.gedit-plugin
: https://gist.github.com/976500 - for
file-search/ui.py
: https://gist.github.com/977770 - for
Makefile
: https://gist.github.com/977758 - for
.gitignore
: https://gist.github.com/977772 - translation in French (
.po
file): https://gist.github.com/977761
Ok, pushed to i18n branch now (https://github.com/oliver/gedit-file-search/tree/i18n) - thanks a lot!
Btw. should the .pot file be checked in as well?
Thanks!
Btw. should the .pot file be checked in as well?
I don't think it should be versioned, because it's automatically generated with make pot
.