i18n.js 420 Bytes
Newer Older
朱国瑞's avatar
朱国瑞 committed
1 2 3
import { createI18n } from 'vue-i18n' //引入vue-i18n组件
import messages from './index'
const language = (
朱国瑞's avatar
朱国瑞 committed
4
  (navigator.language ? navigator.language : navigator.userLanguage) || "en"
朱国瑞's avatar
朱国瑞 committed
5 6
).toLowerCase();
const i18n = createI18n({
朱国瑞's avatar
朱国瑞 committed
7
  fallbackLocale: 'en',
朱国瑞's avatar
朱国瑞 committed
8 9
  globalInjection:true,
  legacy: false, // you must specify 'legacy: false' option
朱国瑞's avatar
朱国瑞 committed
10
  locale: language.split("-")[0] || "en",
朱国瑞's avatar
朱国瑞 committed
11 12 13 14 15
  messages,
});
 
export default i18n