Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2344 from getnikola/cache-messages
Cache messages that we have already loaded.
  • Loading branch information
Kwpolska committed May 20, 2016
2 parents 67f6a0c + d3739bf commit f9319f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -10,6 +10,7 @@ Features
Bugfixes
--------

* Cache theme messages after loading once (Issue #2344)
* Add ``<link>`` tags to other languages even if the post is
untranslated (Google complained otherwise)
* Don't call sys.exit() from plugins if possible (Issue #1839)
Expand Down
9 changes: 6 additions & 3 deletions nikola/nikola.py
Expand Up @@ -337,6 +337,7 @@ def __init__(self, **config):
self._scanned = False
self._template_system = None
self._THEMES = None
self._MESSAGES = None
self.debug = DEBUG
self.loghandlers = utils.STDERR_HANDLER # TODO remove on v8
self.colorful = config.pop('__colorful__', False)
Expand Down Expand Up @@ -1069,9 +1070,11 @@ def _get_themes(self):

def _get_messages(self):
try:
return utils.load_messages(self.THEMES,
self.translations,
self.default_lang)
if self._MESSAGES is None:
self._MESSAGES = utils.load_messages(self.THEMES,
self.translations,
self.default_lang)
return self._MESSAGES
except utils.LanguageNotFoundError as e:
utils.LOGGER.error('''Cannot load language "{0}". Please make sure it is supported by Nikola itself, or that you have the appropriate messages files in your themes.'''.format(e.lang))
sys.exit(1)
Expand Down

0 comments on commit f9319f9

Please sign in to comment.