Attribute fallback i18n strings with lang attribute (#7323)
* add lang attribute to fallback translations Signed-off-by: Kerry Archibald <kerrya@element.io> * readability improvement Signed-off-by: Kerry Archibald <kerrya@element.io> * split _t and _tDom Signed-off-by: Kerry <kerry@Kerrys-MBP.fritz.box> * use tDom in HomePage Signed-off-by: Kerry Archibald <kerrya@element.io> * lint Signed-off-by: Kerry Archibald <kerrya@element.io> * bump matrix-web-i18n Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
parent
ea7ac453bc
commit
7f13a1b40a
7 changed files with 236 additions and 132 deletions
|
@ -1,10 +1,14 @@
|
|||
const en = require("../src/i18n/strings/en_EN");
|
||||
const de = require("../src/i18n/strings/de_DE");
|
||||
const lv = {
|
||||
"Save": "Saglabāt",
|
||||
};
|
||||
|
||||
// Mock the browser-request for the languageHandler tests to return
|
||||
// Fake languages.json containing references to en_EN and de_DE
|
||||
// Fake languages.json containing references to en_EN, de_DE and lv
|
||||
// en_EN.json
|
||||
// de_DE.json
|
||||
// lv.json - mock version with few translations, used to test fallback translation
|
||||
module.exports = jest.fn((opts, cb) => {
|
||||
const url = opts.url || opts.uri;
|
||||
if (url && url.endsWith("languages.json")) {
|
||||
|
@ -17,11 +21,17 @@ module.exports = jest.fn((opts, cb) => {
|
|||
"fileName": "de_DE.json",
|
||||
"label": "German",
|
||||
},
|
||||
"lv": {
|
||||
"fileName": "lv.json",
|
||||
"label": "Latvian"
|
||||
}
|
||||
}));
|
||||
} else if (url && url.endsWith("en_EN.json")) {
|
||||
cb(undefined, {status: 200}, JSON.stringify(en));
|
||||
} else if (url && url.endsWith("de_DE.json")) {
|
||||
cb(undefined, {status: 200}, JSON.stringify(de));
|
||||
} else if (url && url.endsWith("lv.json")) {
|
||||
cb(undefined, {status: 200}, JSON.stringify(lv));
|
||||
} else {
|
||||
cb(true, {status: 404}, "");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue