Skip to content
Permalink
Browse files

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 f9319f98238f38318dab94aa59cc3ab1280ce117
Showing with 7 additions and 3 deletions.
  1. +1 −0 CHANGES.txt
  2. +6 −3 nikola/nikola.py
@@ -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)
@@ -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)
@@ -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)

0 comments on commit f9319f9

Please sign in to comment.
You can’t perform that action at this time.