/* * third.ts * Copyright (C) 2024 veypi * 2024-10-29 19:52 * Distributed under terms of the GPL license. */ import oneicon from '@veypi/one-icon' import { createI18n } from 'vue-i18n' import langEn from './i18n/en' import langZh from './i18n/zh' const navLang = navigator.language; //判断当前浏览器使用的语言 const localLang = navLang === 'zh-CN' ? 'zh-CN' : 'en-US'; let lang = localStorage.getItem('lang') || localLang || 'en-US'; export const i18n = createI18n({ locale: lang, fallbackLocale: 'en', messages: { en: langEn, zh: langZh, }, modifiers: { snakeCase: (str: any) => str.split(' ').join('_') } }); export default defineNuxtPlugin((nuxtApp) => { nuxtApp.vueApp.use(oneicon) nuxtApp.vueApp.use(i18n) })