Skip to content
Permalink
Browse files

Cache messages that we have already loaded.

Messages were being loaded each time the `MESSAGES` attribute of `site`
was accessed. This commit switches to using cached values.
  • Loading branch information
punchagan committed May 19, 2016
1 parent 67f6a0c commit a6ac0f8e105003221dbfcf4e17f16dd642c9ff36
Showing with 6 additions and 3 deletions.
  1. +6 −3 nikola/nikola.py
@@ -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 a6ac0f8

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