Mercurial > boomslang
comparison pyntnclick/main.py @ 786:fb8c146017a9 pyntnclick
Add warnings for 'po file is older than mo file' and 'mo file missing'
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Sat, 26 Jan 2013 20:01:39 +0200 |
parents | cb71ad1fb64b |
children | bdaffaa8b6bf |
comparison
equal
deleted
inserted
replaced
785:cb71ad1fb64b | 786:fb8c146017a9 |
---|---|
4 | 4 |
5 ''' | 5 ''' |
6 import sys | 6 import sys |
7 import gettext | 7 import gettext |
8 import locale | 8 import locale |
9 import os | |
9 from optparse import OptionParser | 10 from optparse import OptionParser |
10 | 11 |
11 import pygame | 12 import pygame |
12 from pygame.locals import SWSURFACE | 13 from pygame.locals import SWSURFACE |
13 | 14 |
71 self.resource = Resources(self._resource_module, lang) | 72 self.resource = Resources(self._resource_module, lang) |
72 gettext.bindtextdomain(self.constants.i18n_name, | 73 gettext.bindtextdomain(self.constants.i18n_name, |
73 self.resource.get_resource_path('locale')) | 74 self.resource.get_resource_path('locale')) |
74 gettext.textdomain(self.constants.i18n_name) | 75 gettext.textdomain(self.constants.i18n_name) |
75 | 76 |
77 self._check_translations() | |
78 | |
76 self.sound = Sound(self.resource) | 79 self.sound = Sound(self.resource) |
77 self.debug_options = [] | 80 self.debug_options = [] |
78 self.running = False | 81 self.running = False |
82 | |
83 def _check_translations(self): | |
84 """Check for outdated mo files""" | |
85 popath = self.resource.get_resource_path('po') | |
86 mopath = self.resource.get_resource_path('locale') | |
87 for candidate in os.listdir(popath): | |
88 if candidate.endswith('.po'): | |
89 polang = candidate.split('.', 1)[0] | |
90 pofile = os.path.join(popath, candidate) | |
91 mofile = gettext.find(self.constants.i18n_name, mopath, | |
92 (polang,)) | |
93 if mofile is None: | |
94 print 'Missing mo file for %s' % pofile | |
95 continue | |
96 if os.stat(pofile).st_mtime > os.stat(mofile).st_mtime: | |
97 print 'po file %s is newer than mo file %s' % (pofile, | |
98 mofile) | |
79 | 99 |
80 def initial_state(self): | 100 def initial_state(self): |
81 """Create a copy of the initial game state.""" | 101 """Create a copy of the initial game state.""" |
82 initial_state = state.Game(self) | 102 initial_state = state.Game(self) |
83 initial_state.set_debug_rects(self._debug_rects) | 103 initial_state.set_debug_rects(self._debug_rects) |