Skip to content

Commit b844415

Browse files
committed
fix: default translation language for not found
Signed-off-by: Dayanidhee Singh <[email protected]>
1 parent 96d71b1 commit b844415

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/platform/src/i18n.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,18 @@ async function getTranslation (id: _IdInfo, locale: string): Promise<IntlString
9191
if (messages instanceof Status) {
9292
return messages
9393
}
94-
return id.kind !== undefined
95-
? (messages[id.kind] as Record<string, IntlString>)?.[id.name]
96-
: (messages[id.name] as IntlString)
94+
if (id.kind !== undefined) {
95+
if ((messages[id.kind] as Record<string, IntlString>)?.[id.name] !== undefined) {
96+
return (messages[id.kind] as Record<string, IntlString>)?.[id.name]
97+
} else {
98+
const englishMessages = await loadTranslationsForComponent(id.component, ENGLISH_LOCALE)
99+
if (!(englishMessages instanceof Status)) {
100+
return (englishMessages[id.kind] as Record<string, IntlString>)?.[id.name]
101+
}
102+
}
103+
} else {
104+
return messages[id.name] as IntlString
105+
}
97106
} catch (err) {
98107
const status = unknownError(err)
99108
await setPlatformStatus(status)

0 commit comments

Comments
 (0)