After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 351287 - review and internationalize gimp-python scripts
review and internationalize gimp-python scripts
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Gimp-Python
git master
Other All
: Urgent normal
: 2.4
Assigned To: Manish Singh
GIMP Bugs
Depends on: 346001
Blocks: 104639
 
 
Reported: 2006-08-14 12:51 UTC by Sven Neumann
Modified: 2006-09-21 14:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Translates most of the strings in gimpcons.py and gtkcons.py (4.57 KB, patch)
2006-09-13 09:34 UTC, david gowers
none Details | Review
less agressive change for gtkcons.py and gimpcons.py (3.09 KB, patch)
2006-09-13 18:54 UTC, Sven Neumann
committed Details | Review

Description Sven Neumann 2006-08-14 12:51:14 UTC
If we want to install Python scripts with GIMP 2.4, they should appear in the users language, if possible. Currently, pygimp doesn't have i18n support and no strings are marked for translation. This needs to change.

We should also review what python scripts are generally useful and which only copy existing functionality and/or are meant as examples. The latter scripts should not be installed (and also do not need to be marked for translation).
Comment 1 Sven Neumann 2006-08-14 12:52:30 UTC
Settig on the 2.4 milestone and raising Priority because this would have to be done as soon as possible so that translators get a chance to do their work.
Comment 2 Sven Neumann 2006-08-16 21:01:19 UTC
I have done some minor cleanups to the scripts in preparation of i18n.
Comment 3 david gowers 2006-09-13 09:34:23 UTC
Created attachment 72684 [details] [review]
Translates most of the strings in gimpcons.py and gtkcons.py

"Does this mean that noone is interested in having the existing Python
scripts in GIMP 2.4?"
The console is the only interesting one from my point of view. Though the others serve somewhat well as examples. 

I say 'most' because I wasn't sure whether error messages as in:

   def tell(self):      raise IOError, (29, 'Illegal seek') 

should be translated, so I didn't mark them.

The usage of gettext is extremely simplistic. I've marked the translatable strings just like they are marked in C code : _("Translatable String content")

(after earlier doing 'from gettext import gettext as _')
. I suspect that I need to set a text domain via gettext.textdomain() but I have no idea what it should be.
Comment 4 Sven Neumann 2006-09-13 18:23:30 UTC
We need to introduce a new domain for this. This will probably be called gimp20-python. We also have to figure out if intltool can handle python or if we need to use pyxgettext for this.
Comment 5 Joao S. O. Bueno 2006-09-13 18:39:45 UTC
Intltool gettext can handle python, yes. 
Comment 6 Sven Neumann 2006-09-13 18:53:21 UTC
I tested this and indeed, we can use intltool for this. I will add the necessary framework to CVS, I am also attaching a modified version of David's patch. This one is less agressive about marking strings for translation. Some of the marked strings were not at all displayed anywhere in the UI and some should probably not be translated.
Comment 7 Sven Neumann 2006-09-13 18:54:18 UTC
Created attachment 72715 [details] [review]
less agressive change for gtkcons.py and gimpcons.py
Comment 8 Sven Neumann 2006-09-13 19:16:33 UTC
The basic framework for preparing the translations in the gimp20-python domain is now in CVS:

2006-09-13  Sven Neumann  <sven@gimp.org>

	* Makefile.am
	* configure.in
	* po-python: added basic infrastructure for a gimp20-python
	translation domain.

	* plug-ins/pygimp/plug-ins/gimpcons.py
	* plug-ins/pygimp/plug-ins/gtkcons.py: mark some strings for
	translation, based on a patch from David Gowers (bug #351287).
Comment 9 Sven Neumann 2006-09-14 09:35:17 UTC
For this to actually work, we still need to do something like this:

  import gettext
  t = gettext.translation('gimp20-python', gimp.locale_directory)
  _ = t.ugettext

However we do not want to include such code all over the place. It should probably go into the gimpui module but I haven't yet figured out how to do this.
Comment 10 Sven Neumann 2006-09-15 10:39:50 UTC
I did some more changes and i18n now works for strings in the pygimp module. The plug-ins itself are however not yet properly internationalized. For this to work the plug-in has to register the translation domain with GIMP and call an equivalent to INIT_I18N(). Still not sure how that would be done best.
Comment 11 Joao S. O. Bueno 2006-09-15 11:23:19 UTC
The usual pratice when making a python plug-in is importing the gimp bindings by doing:
from gimpfu import * 

That menas tht binding "_" to the transalsting function in the gimpfu.py namespace would sufice.

However, most third part party plug-ins also do that (from gimpfu import *) )
and doing that means that "_" would be pointing to the pygimp translating domain in all those plug-ins.

I think that creating a very small python module, with little more (if more) than the 3 lines in #9 above - possibly called "pygimp_i18n" and in all plug-ins add a "from pygimp_i18n import *" line.
Comment 12 Sven Neumann 2006-09-15 11:52:37 UTC
I found a solution that works nicely (IMO). The only remaining issue is that one cannot specify the location of the textdomain with the current API. I will look into fixing this but this is only an issue for third-party Python plug-ins.

2006-09-15  Sven Neumann  <sven@gimp.org>

        * plug-ins/pygimp/gimpmodule.c: added domain_register method.

        * plug-ins/pygimp/gimpfu.py: define N_(). Added an optional
        "domain" parameter to the register() method. Register the domain
        with GIMP and initialize gettext if it is specified.

        * plug-ins/pygimp/plug-ins/gimpcons.py: use N_() to mark menu
        label and blurb for translation. Specify the translation domain.

        * plug-ins/pygimp/plug-ins/gtkcons.py: use gettext API for modules.


Now that the framework is implemented, we only need someone to go over the plug-ins, review strings and mark them for translation. gimpcons.py can serve as an example.
Comment 13 Manish Singh 2006-09-17 02:58:48 UTC
Some minor refinements:

2006-09-16  Manish Singh  <yosh@gimp.org>

        * plug-ins/pygimp/gimpfu.py
        * plug-ins/pygimp/plug-ins/gtkcons.py: let the gettext module

        * po-python/POTFILES.in
        * plug-ins/pygimp/gimpui.py: Mark a couple strings for translation
        here.
Comment 14 Sven Neumann 2006-09-19 14:59:26 UTC
Fixed the remaining issue with the framework (not being able to specify the locale directory):

2006-09-19  Sven Neumann  <sven@gimp.org>

        * plug-ins/pygimp/gimpfu.py: allow to pass a (domain, path) tuple
        as value for the domain argument of the register() call. Document
        the domain argument.
Comment 15 Sven Neumann 2006-09-21 14:28:24 UTC
I have prepared all plug-ins for translation and did some minor cleanups, mostly string changes. The changed plug-ins probably need some more testing but I think we can now close this bug-report now.