vue.js如何在I18N语言包中获取当前语言环境

发布于 2025-02-11 18:22:03 字数 483 浏览 5 评论 0原文

我想获得当前的语言环境,因为我需要检查当前的语言环境==='en',然后返回true或false,我该怎么做? vue.js/i18n/vee-valites

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画尸师 2025-02-18 18:22:03

在选项API中使用:

this.$i18n.locale

在组成中,API使用usei18n函数获取语言环境:

const {locale}=useI18n()

In option API use :

this.$i18n.locale

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

const {locale}=useI18n()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文