mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: skip fallbacks in english translation
This commit is contained in:
1 parent
0bb6be0eaf
commit
5409186bf7
2 files changed
+6
-1
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.14.2",
|
||||
"version": "3.14.3",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -7,6 +7,11 @@ declare global {
|
||||
}
|
||||
|
||||
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 locales[languages[0]]?.[this] || locales['en']?.[this] || this;
|
||||
}
|
||||
for (const language of languages) {
|
||||
if (!language) continue;
|
||||
const curr = (locales[language] || {})[this] || (locales[language.split('_')[0]] || {})[this];
|
||||
|
||||
Reference in new issue
Block a user