FEATURE: Support i18n in Ember CLI plugin tests
This commit is contained in:
parent
de3680eb5c
commit
c27e324bd1
|
@ -4,6 +4,8 @@ const fs = require("fs");
|
|||
const concat = require("broccoli-concat");
|
||||
const mergeTrees = require("broccoli-merge-trees");
|
||||
const MessageFormat = require("messageformat");
|
||||
const deepmerge = require("deepmerge");
|
||||
const glob = require("glob");
|
||||
|
||||
let built = false;
|
||||
|
||||
|
@ -40,10 +42,14 @@ class TranslationPlugin extends Plugin {
|
|||
return;
|
||||
}
|
||||
|
||||
let file = this.inputPaths[0] + "/" + this.inputFile;
|
||||
let parsed = {};
|
||||
|
||||
let yaml = fs.readFileSync(file, { encoding: "UTF-8" });
|
||||
let parsed = Yaml.load(yaml);
|
||||
this.inputPaths.forEach((path) => {
|
||||
let file = path + "/" + this.inputFile;
|
||||
let yaml = fs.readFileSync(file, { encoding: "UTF-8" });
|
||||
let loaded = Yaml.load(yaml);
|
||||
parsed = deepmerge(parsed, loaded);
|
||||
});
|
||||
|
||||
let extras = {
|
||||
en: {
|
||||
|
@ -82,11 +88,14 @@ module.exports = function translatePlugin(...params) {
|
|||
};
|
||||
|
||||
module.exports.createI18nTree = function (discourseRoot, vendorJs) {
|
||||
let en = new TranslationPlugin(
|
||||
[discourseRoot + "/config/locales"],
|
||||
"client.en.yml"
|
||||
let translations = [discourseRoot + "/config/locales"].concat(
|
||||
glob
|
||||
.sync(discourseRoot + "/plugins/*/config/locales/client.en.yml")
|
||||
.map((f) => f.replace(/\/client\.en\.yml$/, ""))
|
||||
);
|
||||
|
||||
let en = new TranslationPlugin(translations, "client.en.yml");
|
||||
|
||||
return concat(
|
||||
mergeTrees([
|
||||
vendorJs,
|
||||
|
|
|
@ -22,15 +22,16 @@
|
|||
"@ember/test-helpers": "^2.2.0",
|
||||
"@glimmer/component": "^1.0.0",
|
||||
"@popperjs/core": "2.10.2",
|
||||
"@uppy/utils": "^4.0.3",
|
||||
"@uppy/aws-s3": "^2.0.4",
|
||||
"@uppy/aws-s3-multipart": "^2.1.0",
|
||||
"@uppy/core": "^2.1.0",
|
||||
"@uppy/drop-target": "^1.1.0",
|
||||
"@uppy/utils": "^4.0.3",
|
||||
"@uppy/xhr-upload": "^2.0.4",
|
||||
"admin": "^1.0.0",
|
||||
"bent": "^7.3.12",
|
||||
"broccoli-asset-rev": "^3.0.0",
|
||||
"deepmerge": "^4.2.2",
|
||||
"discourse-common": "^1.0.0",
|
||||
"discourse-hbr": "^1.0.0",
|
||||
"discourse-widget-hbs": "^1.0.0",
|
||||
|
|
|
@ -4526,6 +4526,11 @@ deep-is@^0.1.3, deep-is@~0.1.3:
|
|||
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
|
||||
integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=
|
||||
|
||||
deepmerge@^4.2.2:
|
||||
version "4.2.2"
|
||||
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955"
|
||||
integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==
|
||||
|
||||
defaults@^1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d"
|
||||
|
|
Loading…
Reference in New Issue