This commit is contained in:
undefined committed 2023-01-10 21:59:44 +08:00
1 parent ba4c5b03d2
commit 18d59edc82
1 file changed
+2 -2
+2 -2
View File
@@ -42,14 +42,14 @@ String.prototype.translate = function translate(...languages: string[]) {
if (languages[0]?.startsWith('en')) { if (languages[0]?.startsWith('en')) {
// For most use cases, source text equals to translated text in English. // 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. // 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)) { for (const language of languages.filter(Boolean)) {
const curr = app.i18n.get(this, language) || app.i18n.get(this, language.split('_')[0]) const curr = app.i18n.get(this, language) || app.i18n.get(this, language.split('_')[0])
|| app.i18n.get(this, language.split('-')[0]); || app.i18n.get(this, language.split('-')[0]);
if (curr) return curr; if (curr) return curr;
} }
return this; return this.toString();
}; };
/** @deprecated use ctx.i18n.load instead. */ /** @deprecated use ctx.i18n.load instead. */