|
|
@@ -12,8 +12,18 @@ const messages = {
|
|
|
'zh-Hans': zhHans, // key 不能乱写,查看截图 screenshots/i18n.png
|
|
|
bn,
|
|
|
}
|
|
|
+
|
|
|
+const supportedLocales = ['en', 'zh-Hans', 'bn'] as const
|
|
|
+type SupportedLocale = typeof supportedLocales[number]
|
|
|
+
|
|
|
+function normalizeLocale(locale: string | undefined | null): SupportedLocale {
|
|
|
+ if (supportedLocales.includes(locale as SupportedLocale))
|
|
|
+ return locale as SupportedLocale
|
|
|
+ return 'bn'
|
|
|
+}
|
|
|
+
|
|
|
const i18n = createI18n({
|
|
|
- locale: uni.getLocale() === 'bn' ? 'bn' : 'bn', // 获取已设置的语言,fallback 语言需要再 manifest.config.ts 中设置
|
|
|
+ locale: normalizeLocale(uni.getLocale()), // 获取已设置的语言,fallback 语言需要再 manifest.config.ts 中设置
|
|
|
messages,
|
|
|
allowComposition: true,
|
|
|
})
|