core: bug fix

This commit is contained in:
undefined committed 2022-06-29 00:31:44 +08:00
1 parent 5409186bf7
commit e4ce668850
1 file changed
+1 -1
+1 -1
View File
@@ -7,7 +7,7 @@ declare global {
}
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.
// So if it doesn't exist, we should use the original text instead of fallback.
return locales[languages[0]]?.[this] || locales['en']?.[this] || this;