[gedit-plugins] Fix gettext import in Python files with translations



commit 53f310f2968a18438e47831247fa389e13ab9ed8
Author: Piotr Drąg <piotrdrag gmail com>
Date:   Sun Jan 28 22:17:05 2018 +0100

    Fix gettext import in Python files with translations
    
    https://bugzilla.gnome.org/show_bug.cgi?id=790383

 plugins/charmap/charmap/__init__.py              |    7 ++++---
 plugins/codecomment/codecomment.py               |    7 ++++---
 plugins/colorpicker/colorpicker.py               |    7 ++++---
 plugins/colorschemer/schemer/__init__.py         |    8 ++++++++
 plugins/commander/commander/appactivatable.py    |    8 ++++++++
 plugins/commander/commander/windowactivatable.py |    6 ------
 plugins/dashboard/dashboard/dashboard.py         |    8 ++++++++
 plugins/joinlines/joinlines.py                   |    7 ++++---
 plugins/multiedit/multiedit/appactivatable.py    |    8 ++++++++
 plugins/multiedit/multiedit/viewactivatable.py   |    8 +++++---
 plugins/multiedit/multiedit/windowactivatable.py |    6 ------
 plugins/synctex/synctex/synctex.py               |    7 ++++---
 plugins/terminal/terminal.py                     |    7 ++++---
 plugins/textsize/textsize/__init__.py            |    7 ++++---
 plugins/translate/translate/__init__.py          |    7 ++++---
 15 files changed, 69 insertions(+), 39 deletions(-)
---
diff --git a/plugins/charmap/charmap/__init__.py b/plugins/charmap/charmap/__init__.py
index f7016e4..3cb2600 100644
--- a/plugins/charmap/charmap/__init__.py
+++ b/plugins/charmap/charmap/__init__.py
@@ -18,7 +18,6 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
 import sys
-import gettext
 
 import gi
 gi.require_version('Gedit', '3.0')
@@ -30,8 +29,10 @@ from .panel import CharmapPanel
 from gpdefs import *
 
 try:
-    gettext.bindtextdomain(GETTEXT_PACKAGE, GP_LOCALEDIR)
-    _ = lambda s: gettext.dgettext(GETTEXT_PACKAGE, s);
+    import gettext
+    gettext.bindtextdomain('gedit-plugins')
+    gettext.textdomain('gedit-plugins')
+    _ = gettext.gettext
 except:
     _ = lambda s: s
 
diff --git a/plugins/codecomment/codecomment.py b/plugins/codecomment/codecomment.py
index 4efd3fe..991f968 100644
--- a/plugins/codecomment/codecomment.py
+++ b/plugins/codecomment/codecomment.py
@@ -25,12 +25,13 @@ import gi
 gi.require_version('Gtk', '3.0')
 gi.require_version('GtkSource', '3.0')
 from gi.repository import GObject, Gio, Gtk, GtkSource, Gedit
-import gettext
 from gpdefs import *
 
 try:
-    gettext.bindtextdomain(GETTEXT_PACKAGE, GP_LOCALEDIR)
-    _ = lambda s: gettext.dgettext(GETTEXT_PACKAGE, s);
+    import gettext
+    gettext.bindtextdomain('gedit-plugins')
+    gettext.textdomain('gedit-plugins')
+    _ = gettext.gettext
 except:
     _ = lambda s: s
 
diff --git a/plugins/colorpicker/colorpicker.py b/plugins/colorpicker/colorpicker.py
index aef6cbc..c585115 100644
--- a/plugins/colorpicker/colorpicker.py
+++ b/plugins/colorpicker/colorpicker.py
@@ -25,12 +25,13 @@ gi.require_version('Gtk', '3.0')
 gi.require_version('Gedit', '3.0')
 from gi.repository import GObject, Gio, Gtk, Gdk, Gedit
 import re
-import gettext
 from gpdefs import *
 
 try:
-    gettext.bindtextdomain(GETTEXT_PACKAGE, GP_LOCALEDIR)
-    _ = lambda s: gettext.dgettext(GETTEXT_PACKAGE, s)
+    import gettext
+    gettext.bindtextdomain('gedit-plugins')
+    gettext.textdomain('gedit-plugins')
+    _ = gettext.gettext
 except:
     _ = lambda s: s
 
diff --git a/plugins/colorschemer/schemer/__init__.py b/plugins/colorschemer/schemer/__init__.py
index 4307b01..cb3edf0 100644
--- a/plugins/colorschemer/schemer/__init__.py
+++ b/plugins/colorschemer/schemer/__init__.py
@@ -25,6 +25,14 @@ from gi.repository import GObject, Gio, Gedit, Gtk
 import os
 from .schemer import GUI
 
+try:
+    import gettext
+    gettext.bindtextdomain('gedit-plugins')
+    gettext.textdomain('gedit-plugins')
+    _ = gettext.gettext
+except:
+    _ = lambda s: s
+
 
 class AppActivatable(GObject.Object, Gedit.AppActivatable):
 
diff --git a/plugins/commander/commander/appactivatable.py b/plugins/commander/commander/appactivatable.py
index b100370..258efea 100644
--- a/plugins/commander/commander/appactivatable.py
+++ b/plugins/commander/commander/appactivatable.py
@@ -23,6 +23,14 @@ from gi.repository import GLib, GObject, Gio, Gedit
 import sys, os
 import commander.commands as commands
 
+try:
+    import gettext
+    gettext.bindtextdomain('gedit-plugins')
+    gettext.textdomain('gedit-plugins')
+    _ = gettext.gettext
+except:
+    _ = lambda s: s
+
 
 class CommanderAppActivatable(GObject.Object, Gedit.AppActivatable):
 
diff --git a/plugins/commander/commander/windowactivatable.py 
b/plugins/commander/commander/windowactivatable.py
index 9ba2cda..8b6d27f 100644
--- a/plugins/commander/commander/windowactivatable.py
+++ b/plugins/commander/commander/windowactivatable.py
@@ -24,12 +24,6 @@ from entry import Entry
 from info import Info
 from gpdefs import *
 
-try:
-    gettext.bindtextdomain(GETTEXT_PACKAGE, GP_LOCALEDIR)
-    _ = lambda s: gettext.dgettext(GETTEXT_PACKAGE, s);
-except:
-    _ = lambda s: s
-
 class CommanderWindowActivatable(GObject.Object, Gedit.WindowActivatable):
 
     window = GObject.Property(type=Gedit.Window)
diff --git a/plugins/dashboard/dashboard/dashboard.py b/plugins/dashboard/dashboard/dashboard.py
index 734a467..c203c0d 100644
--- a/plugins/dashboard/dashboard/dashboard.py
+++ b/plugins/dashboard/dashboard/dashboard.py
@@ -29,6 +29,14 @@ import urllib
 import dbus
 import datetime
 
+try:
+    import gettext
+    gettext.bindtextdomain('gedit-plugins')
+    gettext.textdomain('gedit-plugins')
+    _ = gettext.gettext
+except:
+    _ = lambda s: s
+
 CLIENT = Zeitgeist.Log.get_default()
 
 try:
diff --git a/plugins/joinlines/joinlines.py b/plugins/joinlines/joinlines.py
index 5548350..275d9e2 100644
--- a/plugins/joinlines/joinlines.py
+++ b/plugins/joinlines/joinlines.py
@@ -20,12 +20,13 @@
 #  Boston, MA 02110-1301, USA.
 
 from gi.repository import GObject, Gio, Gtk, Gedit
-import gettext
 from gpdefs import *
 
 try:
-    gettext.bindtextdomain(GETTEXT_PACKAGE, GP_LOCALEDIR)
-    _ = lambda s: gettext.dgettext(GETTEXT_PACKAGE, s)
+    import gettext
+    gettext.bindtextdomain('gedit-plugins')
+    gettext.textdomain('gedit-plugins')
+    _ = gettext.gettext
 except:
     _ = lambda s: s
 
diff --git a/plugins/multiedit/multiedit/appactivatable.py b/plugins/multiedit/multiedit/appactivatable.py
index 4dd845d..ff6b152 100644
--- a/plugins/multiedit/multiedit/appactivatable.py
+++ b/plugins/multiedit/multiedit/appactivatable.py
@@ -21,6 +21,14 @@
 
 from gi.repository import GObject, Gio, Gedit
 
+try:
+    import gettext
+    gettext.bindtextdomain('gedit-plugins')
+    gettext.textdomain('gedit-plugins')
+    _ = gettext.gettext
+except:
+    _ = lambda s: s
+
 
 class MultiEditAppActivatable(GObject.Object, Gedit.AppActivatable):
 
diff --git a/plugins/multiedit/multiedit/viewactivatable.py b/plugins/multiedit/multiedit/viewactivatable.py
index beff205..d063f99 100644
--- a/plugins/multiedit/multiedit/viewactivatable.py
+++ b/plugins/multiedit/multiedit/viewactivatable.py
@@ -19,7 +19,7 @@
 #  Foundation, Inc., 51 Franklin Street, Fifth Floor,
 #  Boston, MA 02110-1301, USA.
 
-import re, time, gettext
+import re, time
 import xml.sax.saxutils
 
 from gi.repository import GLib, GObject, Pango, PangoCairo, Gdk, Gtk, Gedit
@@ -28,8 +28,10 @@ from .signals import Signals
 from gpdefs import *
 
 try:
-    gettext.bindtextdomain(GETTEXT_PACKAGE, GP_LOCALEDIR)
-    _ = lambda s: gettext.dgettext(GETTEXT_PACKAGE, s);
+    import gettext
+    gettext.bindtextdomain('gedit-plugins')
+    gettext.textdomain('gedit-plugins')
+    _ = gettext.gettext
 except:
     _ = lambda s: s
 
diff --git a/plugins/multiedit/multiedit/windowactivatable.py 
b/plugins/multiedit/multiedit/windowactivatable.py
index ca2426b..a027bb0 100644
--- a/plugins/multiedit/multiedit/windowactivatable.py
+++ b/plugins/multiedit/multiedit/windowactivatable.py
@@ -23,14 +23,8 @@ from gi.repository import GLib, GObject, Gio, Gedit
 
 from .viewactivatable import MultiEditViewActivatable
 
-import gettext
 from gpdefs import *
 
-try:
-    gettext.bindtextdomain(GETTEXT_PACKAGE, GP_LOCALEDIR)
-    _ = lambda s: gettext.dgettext(GETTEXT_PACKAGE, s);
-except:
-    _ = lambda s: s
 
 class MultiEditWindowActivatable(GObject.Object, Gedit.WindowActivatable):
 
diff --git a/plugins/synctex/synctex/synctex.py b/plugins/synctex/synctex/synctex.py
index 5636f33..b6ddc7c 100644
--- a/plugins/synctex/synctex/synctex.py
+++ b/plugins/synctex/synctex/synctex.py
@@ -24,14 +24,15 @@ from gi.repository import GObject, Pango, Gtk, Gedit, Peas, PeasGtk, Gio, Gdk
 from .evince_dbus import EvinceWindowProxy
 import dbus.mainloop.glib
 import logging
-import gettext
 import os
 import re
 from gpdefs import *
 
 try:
-    gettext.bindtextdomain(GETTEXT_PACKAGE, GP_LOCALEDIR)
-    _ = lambda s: gettext.dgettext(GETTEXT_PACKAGE, s);
+    import gettext
+    gettext.bindtextdomain('gedit-plugins')
+    gettext.textdomain('gedit-plugins')
+    _ = gettext.gettext
 except:
     _ = lambda s: s
 
diff --git a/plugins/terminal/terminal.py b/plugins/terminal/terminal.py
index c177b9f..8402427 100644
--- a/plugins/terminal/terminal.py
+++ b/plugins/terminal/terminal.py
@@ -21,7 +21,6 @@
 # Boston, MA  02110-1301  USA
 
 import os
-import gettext
 
 import gi
 gi.require_version('Gedit', '3.0')
@@ -32,8 +31,10 @@ from gi.repository import GObject, GLib, Gio, Pango, Gdk, Gtk, Gedit, Vte
 from gpdefs import *
 
 try:
-    gettext.bindtextdomain(GETTEXT_PACKAGE, GP_LOCALEDIR)
-    _ = lambda s: gettext.dgettext(GETTEXT_PACKAGE, s);
+    import gettext
+    gettext.bindtextdomain('gedit-plugins')
+    gettext.textdomain('gedit-plugins')
+    _ = gettext.gettext
 except:
     _ = lambda s: s
 
diff --git a/plugins/textsize/textsize/__init__.py b/plugins/textsize/textsize/__init__.py
index 377616d..594076e 100644
--- a/plugins/textsize/textsize/__init__.py
+++ b/plugins/textsize/textsize/__init__.py
@@ -27,12 +27,13 @@ gi.require_version('Gtk', '3.0')
 gi.require_version('Gedit', '3.0')
 from gi.repository import GObject, Gio, Gtk, Gdk, Gedit
 from .viewactivatable import TextSizeViewActivatable
-import gettext
 from gpdefs import *
 
 try:
-    gettext.bindtextdomain(GETTEXT_PACKAGE, GP_LOCALEDIR)
-    _ = lambda s: gettext.dgettext(GETTEXT_PACKAGE, s);
+    import gettext
+    gettext.bindtextdomain('gedit-plugins')
+    gettext.textdomain('gedit-plugins')
+    _ = gettext.gettext
 except:
     _ = lambda s: s
 
diff --git a/plugins/translate/translate/__init__.py b/plugins/translate/translate/__init__.py
index 6afa38d..57bd51b 100644
--- a/plugins/translate/translate/__init__.py
+++ b/plugins/translate/translate/__init__.py
@@ -28,12 +28,13 @@ from .services.apertium import Apertium
 from .translateview import TranslateView
 from .preferences import Preferences
 from .settings import Settings
-import gettext
 from gpdefs import *
 
 try:
-    gettext.bindtextdomain(GETTEXT_PACKAGE, GP_LOCALEDIR)
-    _ = lambda s: gettext.dgettext(GETTEXT_PACKAGE, s);
+    import gettext
+    gettext.bindtextdomain('gedit-plugins')
+    gettext.textdomain('gedit-plugins')
+    _ = gettext.gettext
 except:
     _ = lambda s: s
 


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