Mercurial > boomslang
diff 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 |
line wrap: on
line diff
--- a/pyntnclick/main.py Sat Jan 26 19:41:14 2013 +0200 +++ b/pyntnclick/main.py Sat Jan 26 20:01:39 2013 +0200 @@ -6,6 +6,7 @@ import sys import gettext import locale +import os from optparse import OptionParser import pygame @@ -73,10 +74,29 @@ self.resource.get_resource_path('locale')) gettext.textdomain(self.constants.i18n_name) + self._check_translations() + self.sound = Sound(self.resource) self.debug_options = [] self.running = False + def _check_translations(self): + """Check for outdated mo files""" + popath = self.resource.get_resource_path('po') + mopath = self.resource.get_resource_path('locale') + for candidate in os.listdir(popath): + if candidate.endswith('.po'): + polang = candidate.split('.', 1)[0] + pofile = os.path.join(popath, candidate) + mofile = gettext.find(self.constants.i18n_name, mopath, + (polang,)) + if mofile is None: + print 'Missing mo file for %s' % pofile + continue + if os.stat(pofile).st_mtime > os.stat(mofile).st_mtime: + print 'po file %s is newer than mo file %s' % (pofile, + mofile) + def initial_state(self): """Create a copy of the initial game state.""" initial_state = state.Game(self)