import { createI18n } from 'vue-i18n';
import { useAppStore } from '@/store/modules/app';

import { store } from '@/store/index';   // 因为不是在setup环境而是js中,必须重新初始化加载store
const appStore = useAppStore(store); //pinia


// const appStore = useAppStore();
// 本地语言包
import enLocale from './package/en';
import zhCnLocale from './package/zh-cn';

const messages = {
  'zh-cn': {
    ...zhCnLocale
  },
  en: {
    ...enLocale
  }
};

const i18n = createI18n({
  legacy: false,
  locale: appStore.language,
  messages: messages,
  globalInjection: true
});

export default i18n;
