diff --git a/services/i18n.js b/services/i18n.js index 9d74ec0e4..338f6680a 100644 --- a/services/i18n.js +++ b/services/i18n.js @@ -41,7 +41,7 @@ const loadPluginTranslations = () => { } // Load the plugin translations. - plugins.forEach('server', 'translations').forEach(({plugin, translations: filename}) => { + plugins.get('server', 'translations').forEach(({plugin, translations: filename}) => { debug(`added plugin '${plugin.name}'`); const pack = yaml.parse(fs.readFileSync(filename, 'utf8')); @@ -62,11 +62,6 @@ const i18n = { * Create the new Task kue. */ init(req) { - - // Loads the translations into the translations array from plugins. This is - // done lazily to ensure that we don't have an import cycle. - loadPluginTranslations(); - const lang = accepts(req).language(languages); language = lang ? lang : defaultLanguage; }, @@ -76,6 +71,10 @@ const i18n = { */ t(key, ...replacements) { + // Loads the translations into the translations array from plugins. This is + // done lazily to ensure that we don't have an import cycle. + loadPluginTranslations(); + // Check if the translation exists on the object. if (_.has(translations[language], key)) { diff --git a/services/mailer.js b/services/mailer.js index a4f694b30..0a085ea4a 100644 --- a/services/mailer.js +++ b/services/mailer.js @@ -99,8 +99,8 @@ const mailer = module.exports = { attachLocals(locals); - // Attach the templating function. - locals['t'] = i18n.t; + // Attach the translation function. + locals.t = i18n.t; return Promise.all([ @@ -112,7 +112,7 @@ const mailer = module.exports = { ]) .then(([html, text]) => { - // Create the job. + // Create the job. return mailer.task.create({ title: 'Mail', message: {