pull/490/head
undefined 2 years ago
parent ba4c5b03d2
commit 18d59edc82

@ -42,14 +42,14 @@ String.prototype.translate = function translate(...languages: string[]) {
if (languages[0]?.startsWith('en')) {
// For most use cases, source text equals to translated text in English.
// So if it doesn't exist, we should use the original text instead of fallback.
return app.i18n.get(this, languages[0]) || app.i18n.get(this, 'en') || this;
return app.i18n.get(this, languages[0]) || app.i18n.get(this, 'en') || this.toString();
}
for (const language of languages.filter(Boolean)) {
const curr = app.i18n.get(this, language) || app.i18n.get(this, language.split('_')[0])
|| app.i18n.get(this, language.split('-')[0]);
if (curr) return curr;
}
return this;
return this.toString();
};
/** @deprecated use ctx.i18n.load instead. */

Loading…
Cancel
Save