[英]Vue.js how to get current locale in i18n language package
i want to get my current locale , because i need to check if the current locale === 'en' then return true or false, how can i do this?我想获取我当前的语言环境,因为我需要检查当前语言环境 === 'en' 然后返回 true 或 false,我该怎么做? Vue.js/i18n/vee-validate
Vue.js/i18n/vee-validate
main.js :主.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");
In option API use :在选项 API 中使用:
this.$i18n.locale
in composition API use the useI18n
function to get the locale :在组合 API 中使用
useI18n
函数来获取语言环境:
const {locale}=useI18n()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.