Permalink
Browse files

handle incomplete translations better

  • Loading branch information...
1 parent 62067c0 commit 0b38d80dfebec98f38ab0c89cf290421941beb06 @ralsina committed Oct 2, 2012
Showing with 10 additions and 4 deletions.
  1. +1 −0 CHANGES.txt
  2. +0 −4 nikola/nikola.py
  3. +9 −0 nikola/utils.py
View
@@ -15,6 +15,7 @@ Bugfixes
* Fixed doc installation
* Put webassets cache in cache/webassets
* Update to doit 0.17
+* Don't crash on incomplete translations
New in Version 4.0.3
====================
View
@@ -80,10 +80,6 @@ def __init__(self, **config):
self.config['TRANSLATIONS'] = self.config.get('TRANSLATIONS',
{self.config['DEFAULT_LANG']: ''})
- # FIXME: find way to achieve this with the plugins
- #if self.config['USE_BUNDLES'] and not webassets:
- #self.config['USE_BUNDLES'] = False
-
self.GLOBAL_CONTEXT = self.config.get('GLOBAL_CONTEXT', {})
self.THEMES = utils.get_theme_chain(self.config['THEME'])
View
@@ -157,14 +157,23 @@ def load_messages(themes, translations):
and "younger" themes have priority.
"""
messages = defaultdict(dict)
+ warned = []
for theme_name in themes[::-1]:
msg_folder = os.path.join(get_theme_path(theme_name), 'messages')
oldpath = sys.path
sys.path.insert(0, msg_folder)
+ english = __import__('en')
for lang in translations.keys():
# If we don't do the reload, the module is cached
translation = __import__(lang)
reload(translation)
+ if sorted(translation.MESSAGES.keys()) !=\
+ sorted(english.MESSAGES.keys()) and \
+ lang not in warned:
+ # FIXME: get real logging in place
+ print "Warning: Incomplete translation for language '%s'." % lang
+ warned.append(lang)
+ messages[lang].update(english.MESSAGES)
messages[lang].update(translation.MESSAGES)
del(translation)
sys.path = oldpath

0 comments on commit 0b38d80

Please sign in to comment.