mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +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')) {
|
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. */
|
||||||
|
|||||||
Reference in new issue
Block a user