mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix #483
This commit is contained in:
1 parent
ba4c5b03d2
commit
18d59edc82
1 file changed
+2
-2
@@ -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. */
|
||||
|
||||
Reference in new issue
Block a user