diff pyntnclick/main.py @ 769:43b49f1de828 pyntnclick-i18n

Merge i18n for before the pyntnclick split
author Stefano Rivera <stefano@rivera.za.net>
date Sat, 26 Jan 2013 16:57:33 +0200
parents f4853f817a7a
children c91c613ae6d0
line wrap: on
line diff
--- a/pyntnclick/main.py	Sat Jan 26 13:24:01 2013 +0200
+++ b/pyntnclick/main.py	Sat Jan 26 16:57:33 2013 +0200
@@ -4,6 +4,8 @@
 
 '''
 import sys
+import gettext
+import locale
 from optparse import OptionParser
 
 import pygame
@@ -60,9 +62,18 @@
         self._debug_rects = False
         self._screens = self.SCREENS.copy()
         self._screens['game'] = GameScreen
-        self.resource = Resources(self._resource_module)
+        self.constants = self.game_constants()
+
+        locale.setlocale(locale.LC_ALL, "")
+        lang = locale.getlocale()[0]
+        if '_' in lang:
+            lang = lang.split('_', 1)[0]
+        self.resource = Resources(self._resource_module, lang)
+        gettext.bindtextdomain(self.constants.i18n_name,
+                               self.resource.get_resource_path('locale'))
+        gettext.textdomain(self.constants.i18n_name)
+
         self.sound = Sound(self.resource)
-        self.constants = self.game_constants()
         self.debug_options = []
         self.running = False