diff options
Diffstat (limited to 'lib/output/website/prepareI18n.js')
-rw-r--r-- | lib/output/website/prepareI18n.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/output/website/prepareI18n.js b/lib/output/website/prepareI18n.js new file mode 100644 index 0000000..b57d178 --- /dev/null +++ b/lib/output/website/prepareI18n.js @@ -0,0 +1,30 @@ +var path = require('path'); + +var fs = require('../../utils/fs'); +var Promise = require('../../utils/promise'); +var listSearchPaths = require('./listSearchPaths'); + +/** + Prepare i18n, load translations from plugins and book + + @param {Output} + @return {Promise<Output>} +*/ +function prepareI18n(output) { + var state = output.getState(); + var i18n = state.getI18n(); + var searchPaths = listSearchPaths(output); + + searchPaths + .reverse() + .forEach(function(searchPath) { + var i18nRoot = path.resolve(searchPath, '_i18n'); + + if (!fs.existsSync(i18nRoot)) return; + i18n.load(i18nRoot); + }); + + return Promise(output); +} + +module.exports = prepareI18n; |