我正在尝试将我的 Vue3(带有 Vite 设置)项目国际化,并且@intlify/vite-plugin-vue-i18n我正在使用<script setup>
我不断得到Uncaught TypeError: i18n.global is undefined,但一切似乎都是正确的。我什至尝试过官方文档中的原始代码,您可以在这里找到
无论我做什么,Vue 或 i18n 都找不到globali18n 的属性。
所以我的 i18n.js 是这样的:
import { nextTick } from "vue";
import { createI18n } from "vue-i18n";
import axios from "axios";
import tr from "../src/locales/tr.json";
import en from "../src/locales/en.json";
export const SUPPORT_LOCALES = ["tr", "en"];
export function setupI18n(options = { locale: "tr" }) {
const i18n = createI18n(options);
setI18nLanguage(i18n, options.locale);
return i18n;
}
export function setI18nLanguage(i18n, locale) {
if …Run Code Online (Sandbox Code Playgroud)