import { createI18n } from 'vue-i18n'
import el_zh_cn from 'element-plus/dist/locale/zh-cn'
import el_en from 'element-plus/dist/locale/en'

import config from "@/config"
import tools from '@/utils/tools'
import zh_cn from '@/locales/lang/zh-cn'
import en from '@/locales/lang/en'

const messages = {
    'zh-cn': {
        ...el_zh_cn,
        ...zh_cn
    },
    'en': {
        ...el_en,
        ...en
    }
}

const i18n = createI18n({
    legacy: false,
    fallbackLocale: 'zh-cn',
    locale: tools.data.get("APP_LANG") || config.LANG,
    globalInjection: true,
    messages,
})

export default i18n;
