6

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

2
  • Do you have vue-i18n installed? Check if its in your package.json or node_modules folder. Commented Feb 27, 2017 at 20:10
  • Hi ... Yes it is installed as i say with npm Install --dev vue-i18n Commented Feb 27, 2017 at 20:30

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

Comments

-1
import Vue from 'vue'

import VueI18n from 'vue-i18n'


Vue.use(VueI18n)

// console.log(navigator.language);
let defaultLang = "zh"

const i18n = new VueI18n({
  locale: defaultLang,//默认语言
  messages: {
    zh:{
      hello:'你好',
      footTitle:['现货交易','采购供应','行情资讯','个人中心']
    },
    en: {
      hello: 'hello',
      footTitle:['Spot Trading','Purchase & Supply','Market Information','Personal Center']
    },
  }
})

export default i18n

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.