diff --git a/build/engines.js b/build/engines.js index d042076..59ab8f6 100644 --- a/build/engines.js +++ b/build/engines.js @@ -12,7 +12,7 @@ const slugify = require('./lib/slugify'); const { stripHtml } = require('string-strip-html'); const markdownIt = require('markdown-it'); -const i18n = require('../lang'); +const i18n = require('./lang'); const mAnchor = require('markdown-it-anchor'); diff --git a/lang/index.js b/build/lang.js similarity index 54% rename from lang/index.js rename to build/lang.js index bfbb034..0873a07 100644 --- a/lang/index.js +++ b/build/lang.js @@ -1,11 +1,12 @@ -const languages = { - en: require('./en'), - es: require('./es'), -}; +const languages = {}; module.exports = exports = function (lang, key, ...args) { - var entry = languages[lang] && languages[lang][key]; + if (!languages[lang]) { + languages[lang] = require('../public/' + lang + '/_strings'); + } + + var entry = languages[lang][key]; if (!entry) entry = languages.en[key]; if (typeof entry === 'function') return entry(...args); return entry || key; diff --git a/build/page-writer.js b/build/page-writer.js index ba32daa..3e36c35 100644 --- a/build/page-writer.js +++ b/build/page-writer.js @@ -5,7 +5,7 @@ const { map, uniq } = require('lodash'); const { resolve, ROOT, TYPE } = require('./resolve'); const { siteInfo } = require(resolve('package.json')); const { minify } = require('html-minifier-terser'); -const i18n = require('../lang'); +const i18n = require('./lang'); const MINIFY_CONFIG = { conservativeCollapse: true, diff --git a/lang/en.js b/public/en/_strings.js similarity index 100% rename from lang/en.js rename to public/en/_strings.js diff --git a/lang/es.js b/public/es/_strings.js similarity index 100% rename from lang/es.js rename to public/es/_strings.js