Adding more internationalization support

This commit is contained in:
Jocelyn Badgley (Twipped)
2021-08-11 11:23:59 -07:00
parent 84133bd212
commit 59e4380906
10 changed files with 115 additions and 78 deletions

View File

@@ -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 markdownEngines = {
@@ -144,6 +144,7 @@ class Injectables {
this.prod = prod;
this.revManifest = revManifest;
this.injections = {};
this.languages = {};
}
_parsePath (tpath, local, type) {
@@ -182,6 +183,7 @@ class Injectables {
icon: this.icon(),
prod: this.production(),
rev: this.rev(),
lang: this.lang(),
};
}
@@ -268,4 +270,12 @@ class Injectables {
};
}
lang () {
return function (key, ...args) {
const { resolve: rval } = args.pop();
const lang = rval('@root.this.page.lang').split('-')[0];
return i18n(lang, key, ...args);
};
}
}