Skip to content

Commit a6ac0f8

Browse files
committedMay 19, 2016
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.
1 parent 67f6a0c commit a6ac0f8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed
 

‎nikola/nikola.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ def __init__(self, **config):
337337
self._scanned = False
338338
self._template_system = None
339339
self._THEMES = None
340+
self._MESSAGES = None
340341
self.debug = DEBUG
341342
self.loghandlers = utils.STDERR_HANDLER # TODO remove on v8
342343
self.colorful = config.pop('__colorful__', False)
@@ -1069,9 +1070,11 @@ def _get_themes(self):
10691070

10701071
def _get_messages(self):
10711072
try:
1072-
return utils.load_messages(self.THEMES,
1073-
self.translations,
1074-
self.default_lang)
1073+
if self._MESSAGES is None:
1074+
self._MESSAGES = utils.load_messages(self.THEMES,
1075+
self.translations,
1076+
self.default_lang)
1077+
return self._MESSAGES
10751078
except utils.LanguageNotFoundError as e:
10761079
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))
10771080
sys.exit(1)

0 commit comments

Comments
 (0)
Please sign in to comment.