changeset 802:5ec7905b2365 pyntnclick

Don't use resource module to find module locale data
author Neil Muller <neil@dip.sun.ac.za>
date Sun, 27 Jan 2013 14:50:33 +0200
parents cc284445181b
children bcc9277a23e6
files pyntnclick/i18n.py pyntnclick/main.py
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pyntnclick/i18n.py	Sun Jan 27 14:47:58 2013 +0200
+++ b/pyntnclick/i18n.py	Sun Jan 27 14:50:33 2013 +0200
@@ -1,7 +1,13 @@
 # internationalization
 
 from gettext import gettext
+from pkg_resources import resource_filename
 
 
 def _(s):
     return unicode(gettext(s), "utf-8")
+
+
+def get_module_locale(module):
+    """Get the locale data from within the module."""
+    return resource_filename(module, 'locale')
--- a/pyntnclick/main.py	Sun Jan 27 14:47:58 2013 +0200
+++ b/pyntnclick/main.py	Sun Jan 27 14:50:33 2013 +0200
@@ -12,7 +12,7 @@
 import pygame
 from pygame.locals import SWSURFACE
 
-from pyntnclick.i18n import _
+from pyntnclick.i18n import _, get_module_locale
 from pyntnclick.engine import Engine
 from pyntnclick.gamescreen import DefMenuScreen, DefEndScreen, GameScreen
 from pyntnclick.constants import GameConstants, DEBUG_ENVVAR
@@ -169,8 +169,9 @@
             if opts.scene is None:
                 print 'Need to supply a scene to use the rect drawer'
                 sys.exit(1)
-            gettext.bindtextdomain('pyntnclick_tools',
-                    self.resource.get_resource_path('locale'))
+            gettext.bindtextdomain('pyntnclick-tools',
+                    get_module_locale(self.resource.DEFAULT_RESOURCE_MODULE))
+            gettext.textdomain('pyntnclick-tools')
             make_rect_display()
             try:
                 self.engine = RectEngine(self, opts.detail)