mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Overriding text with admin_js.*
keys didn't work (#18281)
This commit is contained in:
parent
f91426a7fa
commit
7b243f3955
@ -26,7 +26,7 @@ export default {
|
||||
// Merge any overrides into our object
|
||||
for (const [locale, overrides] of Object.entries(I18n._overrides || {})) {
|
||||
for (const [key, value] of Object.entries(overrides)) {
|
||||
const segs = key.replace(/^admin_js\./, "js.admin.").split(".");
|
||||
const segs = key.replace(/^admin_js\./, "js.").split(".");
|
||||
let node = I18n.translations[locale] || {};
|
||||
|
||||
for (let i = 0; i < segs.length - 1; i++) {
|
||||
|
@ -112,12 +112,17 @@ test("translation overrides", function (assert) {
|
||||
test("translation overrides (admin_js)", function (assert) {
|
||||
I18n._overrides = {
|
||||
fr: {
|
||||
"admin_js.api.both_languages1": "admin.api.both_languages1 (FR override)",
|
||||
"admin_js.api.only_english2": "admin.api.only_english2 (FR override)",
|
||||
"admin_js.admin.api.both_languages1":
|
||||
"admin.api.both_languages1 (FR override)",
|
||||
"admin_js.admin.api.only_english2":
|
||||
"admin.api.only_english2 (FR override)",
|
||||
"admin_js.type_to_filter": "type_to_filter (FR override)",
|
||||
},
|
||||
en: {
|
||||
"admin_js.api.both_languages2": "admin.api.both_languages2 (EN override)",
|
||||
"admin_js.api.only_english1": "admin.api.only_english1 (EN override)",
|
||||
"admin_js.admin.api.both_languages2":
|
||||
"admin.api.both_languages2 (EN override)",
|
||||
"admin_js.admin.api.only_english1":
|
||||
"admin.api.only_english1 (EN override)",
|
||||
},
|
||||
};
|
||||
LocalizationInitializer.initialize(getApplication());
|
||||
@ -145,6 +150,12 @@ test("translation overrides (admin_js)", function (assert) {
|
||||
"admin.api.both_languages2 (FR)",
|
||||
"prefers translation in current locale over override in fallback locale"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
I18n.t("type_to_filter"),
|
||||
"type_to_filter (FR override)",
|
||||
"correctly changes the translation key by removing `admin_js`"
|
||||
);
|
||||
});
|
||||
|
||||
test("translation overrides for MessageFormat strings", function (assert) {
|
||||
|
Loading…
Reference in New Issue
Block a user