Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VueJs and vue-i18n error

im using the Webpack CLI Template.

Then i install https://kazupon.github.io/vue-i18n/ with npm install --save vue-i18n

In my main.js i do the import and set the "en" locale

import Vue from 'vue'
import VueI18n from 'vue-i18n'
import App from './App'
import router from './router'

Vue.use(VueI18n)
Vue.locale('en', {})

new Vue({
  el: '.nwt-mm-app',
  router,
  template: '<App/>',
  components: { App }
})

The console output always says

Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_0_vue___default.a.locale is not a function
    at eval (eval at <anonymous> (app.js:802), <anonymous>:16:45)
    at Object.<anonymous> (app.js:802)
    at __webpack_require__ (app.js:660)
    at fn (app.js:84)
    at Object.<anonymous> (app.js:1176)
    at __webpack_require__ (app.js:660)
    at app.js:709
    at app.js:712

Am i missing somewhat ? Greetings,

Markus

like image 605
DerMakkuz Avatar asked Oct 18 '22 16:10

DerMakkuz


1 Answers

Well, You can check the author's another repo.

https://github.com/kazupon/vue-i18n-alpha-repro

In the demo, the vue-i18n is like:

import Vue from 'vue'
import App from './App'
import VueI18n from 'vue-i18n'
import router from './router'

Vue.use(VueI18n)
const i18n = new VueI18n({
   locale: 'ja',
   messages: {
     ja: {
       hello: 'こんにちは'
     },
     en: {
       hello: 'hello'
     }
    }
   })

 Vue.config.productionTip = false

 /* eslint-disable no-new */
 new Vue({
   el: '#app',
   router,
   i18n,
   template: '<App/>',
   components: { App }
 })

And it works.

like image 159
X Rene Avatar answered Oct 20 '22 10:10

X Rene