[gimp] extensions: fix localization of the Python 3 goat exercise.



commit d4598ddefd7ebcc43c497d189ccc46a0c66b9085
Author: Jehan <jehan girinstud io>
Date:   Sun Oct 18 01:42:37 2020 +0200

    extensions: fix localization of the Python 3 goat exercise.
    
    We must set the correct gettext domain and bind it to the appropriate
    directory for it to be localized appropriately.

 extensions/goat-exercises/goat-exercise-py3.py | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/extensions/goat-exercises/goat-exercise-py3.py b/extensions/goat-exercises/goat-exercise-py3.py
index 89552c5b68..bcf2656083 100755
--- a/extensions/goat-exercises/goat-exercise-py3.py
+++ b/extensions/goat-exercises/goat-exercise-py3.py
@@ -23,9 +23,15 @@ from gi.repository import Gegl
 from gi.repository import GObject
 from gi.repository import GLib
 from gi.repository import Gio
-import sys, os
 
 import gettext
+import os
+import sys
+
+# Set-up localization for your plug-in with your own text domain.
+gettext.bindtextdomain('gimp30-std-plug-ins', Gimp.locale_directory())
+gettext.bind_textdomain_codeset('gimp30-std-plug-ins', 'UTF-8')
+gettext.textdomain('gimp30-std-plug-ins')
 _ = gettext.gettext
 def N_(message): return message
 
@@ -69,9 +75,9 @@ class Goat (Gimp.PlugIn):
                                    title=_("Exercise a goat (Python 3)"),
                                    role="goat-exercise-Python3")
 
-            dialog.add_button("_Cancel", Gtk.ResponseType.CANCEL)
-            dialog.add_button("_Source", Gtk.ResponseType.APPLY)
-            dialog.add_button("_OK", Gtk.ResponseType.OK)
+            dialog.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL)
+            dialog.add_button(_("_Source"), Gtk.ResponseType.APPLY)
+            dialog.add_button(_("_OK"), Gtk.ResponseType.OK)
 
             geometry = Gdk.Geometry()
             geometry.min_aspect = 0.5
@@ -85,10 +91,10 @@ class Goat (Gimp.PlugIn):
             # XXX We use printf-style string for sharing the localized
             # string. You may just use recommended Python format() or
             # any style you like in your plug-ins.
-            head_text=("This plug-in is an exercise in '%s' to "
-                       "demo plug-in creation.\nCheck out the last "
-                       "version of the source code online by clicking "
-                       "the \"Source\" button." % ("Python 3"))
+            head_text=_("This plug-in is an exercise in '%s' to "
+                        "demo plug-in creation.\nCheck out the last "
+                        "version of the source code online by clicking "
+                        "the \"Source\" button.") % ("Python 3")
             label = Gtk.Label(label=head_text)
             box.pack_start(label, False, False, 1)
             label.show()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]