import { createI18n } from 'vue-i18n'
import en from './lang/en'
import zh from './lang/zh'


// 获取当前语言
export function getCurrentLang(): string | null {
  return !!localStorage.getItem('locale') && localStorage.getItem('locale') !== 'null' && localStorage.getItem('locale') !== 'undefine' ? localStorage.getItem('locale') : 'en'
}


// 创建 i18n 实例
const i18n = createI18n({
  legacy: false,
  locale: (getCurrentLang() as string),
  fallbackLocale: 'en',
  messages: {
    en: en,
    "zh-CN": zh,
  },
});



export default i18n