vue-i18n

Vue.js 3 - Error while using VueI18n plugin in vue - Cannot set property '_vm' of undefined

雨燕双飞 提交于 2021-02-16 14:31:11
问题 I've just started working with Vue.js and learning it through some online code snippet and tutorials. I'm trying to implement internationalization support for my vue project, but I'm getting error in web-console. Here are my code snippets main.js import { createApp } from 'vue'; import App from './App.vue'; import VueI18n from 'vue-i18n' import router from './router/index' function loadLocaleMessages () { const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i) const

Vue.js 3 - Error while using VueI18n plugin in vue - Cannot set property '_vm' of undefined

拥有回忆 提交于 2021-02-16 14:31:10
问题 I've just started working with Vue.js and learning it through some online code snippet and tutorials. I'm trying to implement internationalization support for my vue project, but I'm getting error in web-console. Here are my code snippets main.js import { createApp } from 'vue'; import App from './App.vue'; import VueI18n from 'vue-i18n' import router from './router/index' function loadLocaleMessages () { const locales = require.context('./locales', true, /[A-Za-z0-9-_,\s]+\.json$/i) const

how to switch locale with storybook in vue js project via the @storybook/addon-contexts

帅比萌擦擦* 提交于 2021-02-10 15:00:55
问题 I m looking for a sample to be able to switch locale from vue-i18n inside storybook. I have find this addon-context story on the official storybook github but i have some difficulties to make works. I m using storybook v5.3, vue.js v2.6 and vue-i18n v8.15.4. For the moment, i have the globe icon with 2 entries (english and french). But when i switch it has no effect on the vue-i18n locale. // .storybook/main.js module.exports = { stories: ["../../src/**/*.stories.(js|jsx|ts|tsx|mdx)"], addons

Vue-i18n - Cannot read property 'config' of undefined

自古美人都是妖i 提交于 2021-01-26 09:19:03
问题 First of all I show you what works (in App.js) import router from './routes.js'; import VueI18n from 'vue-i18n'; const messages = { en: { message: { hello: 'hello world' } } } // Create VueI18n instance with options const i18n = new VueI18n({ locale: 'en', // set locale messages, // set locale messages }) const app = new Vue({ el: '#app', router, i18n }); But if I want to separate the code in lang.js import VueI18n from 'vue-i18n'; const messages = { en: { message: { hello: 'hello world' } }

Vue.js project using Vue I18n has got the following error: “TypeError: i18n is undefined”

这一生的挚爱 提交于 2020-12-13 04:11:46
问题 I'm trying to add internationalization on my Vue.js project using Vue I18n. I'm using the documentation (i.e. http://kazupon.github.io/vue-i18n/guide/sfc.html#basic-usage), but I've got the following error message: [Vue warn]: Error in render: "TypeError: i18n is undefined" found in ---> <MainNavBar> at src/components/MainNavBar.vue <VApp> <App> at src/App.vue <Root> vue.runtime.esm.js:619 TypeError: "i18n is undefined" $t vue-i18n.esm.js:167 render MainNavBar.vue:33 VueJS 42 <anonymous> main

Prefix routes with locale in vue.js (using vue-i18n)

本小妞迷上赌 提交于 2020-01-02 06:55:32
问题 I have a locale.js file which is responsible for defining user locale. Here it is: import store from '@/vuex/index' let locale const defaultLocale = 'en_US' if (store.getters['auth/authenticated']) { locale = store.getters['auth/currentUser'].locale || defaultLocale } else { if (localStorage.getItem('locale')) { locale = localStorage.getItem('locale') } else { locale = defaultLocale } } export default locale Also I have a i18n.js file which is responsible for making i18n instance which I use

Using kazupon/vue-i18n inside a state of Vuex

家住魔仙堡 提交于 2019-12-14 02:34:40
问题 Using https://github.com/kazupon/vue-i18n for localization Vue.t() || $t() || trans() receive a string which is a key to be translated by vue-i18n Hey guys! I'am trying the following code: import Vue from 'vue' export default { task: { status: [ { id: 'pending', name: Vue.t('pending') }, { id: 'done', name: 'Done' } ] } } That is my state.js which is the state of my VUEX! When I try to use the Vue.t function I have the following error: Uncaught TypeError: _vue2.default.t is not a function My

Vue-i18n Integration by vee-validate not working as described in the documentation

断了今生、忘了曾经 提交于 2019-12-11 19:45:11
问题 Hello I did a copy/paste from the vee-validate documentation into this codesandbox and I get no validation message - just the following error on the console: [vue-i18n] Cannot translate the value of keypath 'validations.messages._default'. Use the value of keypath as default. Is it a bug within vue-validate , vue-i18n, vuejs ? Or should one configurate it somehow different? 回答1: you forgot to initialize i18n After const i18n = new VueI18n(); add this line i18n.locale = "en"; this line tells