import { createI18n } from "vue-i18n"; //引入vue-i18n组件
import messages from "./index";

const nav = (navigator.language ? navigator.language : "zh").toLowerCase();
const initialLocale = nav.startsWith("zh")
  ? "zh_CN"
  : nav.startsWith("en")
    ? "en_US"
    : "zh_CN";

export const i18n = createI18n({
  fallbackLocale: ["zh_CN", "zh", "en_US", "en"],
  globalInjection: true, //设置全局可用
  legacy: false, // you must specify 'legacy: false' option
  locale: initialLocale,
  messages,
  silentTranslationWarn: true, // true - warning off
  missingWarn: false,
  silentFallbackWarn: true,
});
