[mousetrap/gnome3-wip: 151/240] i18n.



commit 43356b730a950e6639f64ea3fc1158f97c697fd9
Author: Stoney Jackson <dr stoney gmail com>
Date:   Tue Jun 24 14:42:36 2014 -0400

    i18n.

 src/mousetrap/gui.py               |    4 ++--
 src/mousetrap/main.py              |    5 ++++-
 src/mousetrap/plugins/eyes.py      |    6 +++---
 src/mousetrap/plugins/interface.py |    4 ++--
 src/mousetrap/vision.py            |    6 +++---
 5 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/src/mousetrap/gui.py b/src/mousetrap/gui.py
index 185699c..1e36cb3 100644
--- a/src/mousetrap/gui.py
+++ b/src/mousetrap/gui.py
@@ -73,12 +73,12 @@ class Pointer(object):
         no change is made.'''
         self._moved = False
         if position is not None:
-            LOGGER.debug('Moving pointer to %s', position)
+            LOGGER.debug(_('Moving pointer to %s'), position)
 
             self._pointer.warp(self._screen, position[0], position[1])
             self._moved = True
         else:
-            LOGGER.debug('Not moving the pointer')
+            LOGGER.debug(_('Not moving the pointer'))
 
     def is_moving(self):
         '''Returns True if last call to set_position passed a non-None value
diff --git a/src/mousetrap/main.py b/src/mousetrap/main.py
index d1d013a..7491214 100644
--- a/src/mousetrap/main.py
+++ b/src/mousetrap/main.py
@@ -2,6 +2,9 @@
 Where it all begins.
 '''
 
+import gettext
+gettext.install('mousetrap')
+
 
 from mousetrap.config import Config
 CONFIG = Config()
@@ -48,7 +51,7 @@ class App(object):
         except ImportError as error:
             print("ERROR")
             LOGGER.error(
-                'Could not import plugin `%s`. Check config file and PYTHONPATH.',
+                _('Could not import plugin `%s`. Check config file and PYTHONPATH.'),
                 class_
                 )
             raise
diff --git a/src/mousetrap/plugins/eyes.py b/src/mousetrap/plugins/eyes.py
index f90be27..e135402 100644
--- a/src/mousetrap/plugins/eyes.py
+++ b/src/mousetrap/plugins/eyes.py
@@ -86,21 +86,21 @@ class LeftEyeLocator(object):
         try:
             face = self._face_detector.detect(image)
 
-            LOGGER.debug("Found the face")
+            LOGGER.debug(_("Found the face"))
         except FeatureNotFoundException:
             return True
 
         try:
             left_eye = self._left_eye_detector.detect(face["image"])
 
-            LOGGER.debug("Found the left eye at %s", left_eye)
+            LOGGER.debug(_("Found the left eye at %s"), left_eye)
         except FeatureNotFoundException:
             return True
 
         try:
             open_eye = self._open_eye_detector.detect(face["image"])
 
-            LOGGER.debug("Found an open eye at %s", open_eye)
+            LOGGER.debug(_("Found an open eye at %s"), open_eye)
 
             return True
         except FeatureNotFoundException:
diff --git a/src/mousetrap/plugins/interface.py b/src/mousetrap/plugins/interface.py
index 695a69c..a6bfd88 100644
--- a/src/mousetrap/plugins/interface.py
+++ b/src/mousetrap/plugins/interface.py
@@ -2,8 +2,8 @@ class Plugin(object):
     def __init__(self, config):
         '''Override to initialize and configure yourself.
         (Do not call parent/this constructor.)'''
-        raise NotImplementedError('Must implement.')
+        raise NotImplementedError(_('Must implement.'))
 
     def run(self, app):
         '''Called each pass of the loop.'''
-        raise NotImplementedError('Must implement.')
+        raise NotImplementedError(_('Must implement.'))
diff --git a/src/mousetrap/vision.py b/src/mousetrap/vision.py
index 23a4311..6d376ed 100644
--- a/src/mousetrap/vision.py
+++ b/src/mousetrap/vision.py
@@ -8,8 +8,8 @@ from mousetrap.image import Image
 
 
 class Camera(object):
-    S_CAPTURE_OPEN_ERROR = 'Device #%d does not support video capture interface'
-    S_CAPTURE_READ_ERROR = 'Error while capturing. Camera disconnected?'
+    S_CAPTURE_OPEN_ERROR = _('Device #%d does not support video capture interface')
+    S_CAPTURE_READ_ERROR = _('Error while capturing. Camera disconnected?')
 
     def __init__(self, config):
         self._config = config
@@ -121,7 +121,7 @@ class FeatureDetector(object):
 
     def _exit_if_none_detected(self):
         if len(self._plural) == 0:
-            raise FeatureNotFoundException('No ' + self._name + 's detected.')
+            raise FeatureNotFoundException(_('Feature not detected: %s') % (self._name))
 
     def _unpack_first(self):
         self._single = dict(zip(['x', 'y', 'width', 'height'], self._plural[0]))


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