[英]Vue i18n - How do I get the current locale inside the i18n component options?
[英]Vue.js how to get current locale in i18n language package
我想获取我当前的语言环境,因为我需要检查当前语言环境 === 'en' 然后返回 true 或 false,我该怎么做? Vue.js/i18n/vee-validate
主.js:
import { createApp } from "vue";
import { createPinia } from "pinia";
import "./index.css";
import App from "./App.vue";
import router from "./router";
import "@/config/vee-validate/rules";
import "@/config/vee-validate/messages";
const app = createApp(App);
app.use(createPinia());
app.use(router);
app.mount("#app");
在选项 API 中使用:
this.$i18n.locale
在组合 API 中使用useI18n
函数来获取语言环境:
const {locale}=useI18n()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.