mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 22:39:36 +08:00
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
import PreloadStore from 'preload-store';
|
|
import LocalizationInitializer from 'discourse/initializers/localization';
|
|
|
|
QUnit.module("initializer:localization", {
|
|
_locale: I18n.locale,
|
|
_translations: I18n.translations,
|
|
|
|
beforeEach() {
|
|
I18n.locale = "fr";
|
|
|
|
I18n.translations = {
|
|
"fr": {
|
|
"js": {
|
|
"composer": {
|
|
"reply": "Répondre"
|
|
}
|
|
}
|
|
},
|
|
"en": {
|
|
"js": {
|
|
"topic": {
|
|
"reply": {
|
|
"help": "begin composing a reply to this topic"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
},
|
|
|
|
afterEach() {
|
|
I18n.locale = this._locale;
|
|
I18n.translations = this._translations;
|
|
}
|
|
});
|
|
|
|
QUnit.test("translation overrides", function(assert) {
|
|
PreloadStore.store('translationOverrides', {"js.composer.reply":"WAT","js.topic.reply.help":"foobar"});
|
|
LocalizationInitializer.initialize(this.registry);
|
|
|
|
assert.equal(I18n.t("composer.reply"), "WAT", "overrides existing translation in current locale");
|
|
assert.equal(I18n.t("topic.reply.help"), "foobar", "overrides translation in default locale");
|
|
});
|