[gimp] extensions: flag labels and documentation strings for localization…
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] extensions: flag labels and documentation strings for localization…
- Date: Sun, 18 Oct 2020 10:00:23 +0000 (UTC)
commit 0d01567b610bca4099a4158780eaeb379c41b4c5
Author: Jehan <jehan girinstud io>
Date: Sun Oct 18 11:55:52 2020 +0200
extensions: flag labels and documentation strings for localization…
… with N_().
Also fix the domain in self.set_translation_domain() call.
Actually I'll have to dig deeper in this function which apparently is
only used for menu entries. Yet it does feel quite redundant with
calling textdomain() and other gettext calls ourselves. Probably we can
make plug-in localization more straightforward.
extensions/goat-exercises/goat-exercise-py3.py | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/extensions/goat-exercises/goat-exercise-py3.py b/extensions/goat-exercises/goat-exercise-py3.py
index bcf2656083..4662ba73e6 100755
--- a/extensions/goat-exercises/goat-exercise-py3.py
+++ b/extensions/goat-exercises/goat-exercise-py3.py
@@ -29,17 +29,22 @@ 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')
+# This is complementary to the gimp_plug_in_set_translation_domain()
+# which is only useful for the menu entries inside GIMP interface,
+# whereas the below calls are used for localization within the plug-in.
+textdomain = 'gimp30-std-plug-ins'
+gettext.bindtextdomain(textdomain, Gimp.locale_directory())
+gettext.bind_textdomain_codeset(textdomain, 'UTF-8')
+gettext.textdomain(textdomain)
_ = gettext.gettext
def N_(message): return message
class Goat (Gimp.PlugIn):
## GimpPlugIn virtual methods ##
def do_query_procedures(self):
- # Localization
- self.set_translation_domain("gimp30-python",
+ # Localization for the menu entries. It has to be called in the
+ # query function only.
+ self.set_translation_domain(textdomain,
Gio.file_new_for_path(Gimp.locale_directory()))
return [ "plug-in-goat-exercise-python" ]
@@ -51,12 +56,12 @@ class Goat (Gimp.PlugIn):
procedure.set_image_types("*")
- procedure.set_menu_label("Exercise a goat and a python")
+ procedure.set_menu_label(N_("Exercise a goat and a python"))
procedure.set_icon_name(GimpUi.ICON_GEGL)
procedure.add_menu_path('<Image>/Filters/Development/Goat exercises/')
- procedure.set_documentation("Exercise a goat in the Python 3 language",
- "Takes a goat for a walk in Python 3",
+ procedure.set_documentation(N_("Exercise a goat in the Python 3 language"),
+ N_("Takes a goat for a walk in Python 3"),
name)
procedure.set_attribution("Jehan", "Jehan", "2019")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]