简体   繁体   中英

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? Vue.js/i18n/vee-validate

main.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 :

this.$i18n.locale

in composition API use the useI18n function to get the locale :

const {locale}=useI18n()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM