jangobango332
jangobango332

Reputation: 91

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");

Upvotes: 0

Views: 2294

Answers (1)

Boussadjra Brahim
Boussadjra Brahim

Reputation: 1

In option API use :

this.$i18n.locale

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

const {locale}=useI18n()

Upvotes: 1

Related Questions