zs
2025-04-28 1f32ea02c1910c417f159cba81a296e66ae7484c
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
55
56
57
58
59
60
61
62
63
64
65
66
// @ts-nocheck
import sdk from 'sdk'
import EN from './i18n/langEN'
import TH from './i18n/langTH'
import ZH from './i18n/langZH'
 
const { models } = sdk
 
export const Language = models.Language
 
export const t = Language.t
 
export const globalT = Language._t
 
export const _t = Language.scope ? Language.scope('MesSuite') : Language._t
 
export const scope = Language.scope || (() => Language._t)
// 暂时方案
// const keys = {}
// export const scope = (key: string) => {
//   const scope = Language.scope || (() => Language._t)
//   const fn = (langKey) => {
//     keys[key] = keys[key] || {}
//     keys[key][langKey] = langKey
//     return scope(key)(langKey)
//   }
//   return fn
// }
 
export const lang = window.app.current.project.current.language
 
export const getLang = (key: string) => {
  const langMap: Record<string, any> = {
    'en-US': EN,
    th: TH,
    'zh-CN': ZH,
    original: ZH,
  }
 
  const langKey: Record<string, string> = {
    'en-US': 'EN',
    th: 'TH',
    'zh-CN': 'ZH',
    original: 'ZH',
  }
 
  return {
    lang: langMap[key] || ZH,
    key: langKey[key],
  }
}
 
export const getScopeT = (namespace?: string) => {
  if (namespace && scope) {
    return scope(namespace)
  }
  return _t
}
 
export const getCurrentLang = () => {
  const lang = window.app.current.project.current.language.followLang
  if (lang.includes('zh')) {
    return 'zh'
  }
  return lang
}