import zhCN from 'antd/locale/zh_CN'
import thTH from 'antd/locale/th_TH'
import enUS from 'antd/locale/en_US'

export type LanguageCode = 'zh-CN' | 'th-TH' | 'lo-LA' | 'en-US'

export interface Language {
  code: LanguageCode
  name: string
  nativeName: string
  flag: string
  antdLocale: any
}

export const languages: Language[] = [
  {
    code: 'zh-CN',
    name: '中文简体',
    nativeName: '中文简体',
    flag: '🇨🇳',
    antdLocale: zhCN
  },
  {
    code: 'th-TH',
    name: '泰语',
    nativeName: 'ไทย',
    flag: '🇹🇭',
    antdLocale: thTH
  },
  {
    code: 'lo-LA',
    name: '老挝语',
    nativeName: 'ລາວ',
    flag: '🇱🇦',
    antdLocale: enUS // Antd没有老挝语，用英语fallback
  },
  {
    code: 'en-US',
    name: '英语',
    nativeName: 'English',
    flag: '🇺🇸',
    antdLocale: enUS
  }
]

export const translations = {
  'zh-CN': zhCNTranslation,
  'th-TH': thTHTranslation,
  'lo-LA': loLATranslation,
  'en-US': enUSTranslation
}

export const getLanguage = (code: LanguageCode): Language => {
  return languages.find(lang => lang.code === code) || languages[0]
}

export const getTranslation = (code: LanguageCode) => {
  return translations[code] || translations['zh-CN']
}

// 导入翻译文件
import zhCNTranslation from './zh-CN'
import thTHTranslation from './th-TH'
import loLATranslation from './lo-LA'
import enUSTranslation from './en-US'
