10.10综合交易所原始源码_移动端
1
admin
2026-02-10 c547081aa61be5c7b6d4c12853c675954c2156eb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { createI18n } from 'vue-i18n'
import { getStorage, getBrowserLang } from '@/utils/index'
import enLocale from './modules/en'
import cnLocale from './modules/CN'
import zhcnLocale from './modules/zh-CN'
import korcnLocale from './modules/Korean'
import japcnLocale from './modules/Japanese'
import Deutsch from './modules/de'
import fr from './modules/fr'
import vi from './modules/vi'
import th from './modules/th'
import gr from './modules/gr'
import Italy from './modules/Italy'
import SpanishLocal from './modules/es'
import PortugueseLocal from './modules/pt'
 
// 支持的 locale 列表,用于校验
const SUPPORTED_LOCALES = ['en', 'CN', 'zh-CN', 'Korean', 'Japanese', 'de', 'fr', 'vi', 'th', 'Italy', 'es', 'pt', 'gr']
 
// 获取初始语言:缓存 > 浏览器语言,并确保在支持列表中
function getInitialLocale() {
  const cached = getStorage('lang')
  if (cached && SUPPORTED_LOCALES.includes(cached)) return cached
  const browserLang = getBrowserLang()
  return SUPPORTED_LOCALES.includes(browserLang) ? browserLang : 'en'
}
 
const messages = {
  en: { ...enLocale },
  CN: { ...cnLocale },
  'zh-CN': { ...zhcnLocale },
  Korean: { ...korcnLocale },
  Japanese: { ...japcnLocale },
  de: { ...Deutsch },
  fr: { ...fr },
  vi: { ...vi },
  th: { ...th },
  Italy: { ...Italy },
  es: { ...SpanishLocal },
  pt: { ...PortugueseLocal },
  gr: { ...gr }
}
 
const i18n = createI18n({
  legacy: false,
  locale: getInitialLocale(),
  fallbackLocale: ['zh-CN', 'en'], // 缺失 key 时先回退到简体中文,再回退到英文
  messages,
  missingWarn: import.meta.env.DEV, // 仅开发环境输出缺失 key 警告
  fallbackWarn: import.meta.env.DEV,
  silentTranslationWarn: !import.meta.env.DEV
})
 
export default i18n