vue-i18n: Vue.locale is not a function - Issue after upgrading to 3.0
I’m getting Unknown TypeError: Vue.locale is not a function
var VueI18n = require('vue-i18n')
Vue.use(VueI18n)
Vue.config.lang = 'sv'
var locales = require('./lang/locales')
Object.keys(locales).forEach(function (lang) {
Vue.locale(lang, locales[lang])
})
And in my locales file I have like I had in 2.*:
module.exports = {
en: {
message: 'Hi',
},
sv: {
message: 'Hej',
}
}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 8
- Comments: 28 (6 by maintainers)
Commits related to this issue
- :pencil: docs: update installation Resolves #28 — committed to kazupon/vue-i18n by kazupon 8 years ago
Can confirm,
npm install vue-i18nis installing"^6.0.0-alpha.2"which is triggering the errorUncaught TypeError: __WEBPACK_IMPORTED_MODULE_0_vue___default.a.locale is not a functionwhen following the getting started guide exactly (setting up before initiating vue-router etc)The error goes away if I manually force in package.json
"vue-i18n": "^5.0.3"I have the same issue (
vue-i18n@^4.0.1) but I do not usevue-router. It is just Vue.js and a custom component. This is my script:The line setting the locale strings (
Vue.locale(lang, locales[lang]);) results in the error _coboo-4a6b9317b0.js:11410 Uncaught TypeError: vue2.default.locale is not a function. Browserify compiles it to:i just move vue-i18n to version 5.0.3 just ok:-)
@r00takaspin Try to use:
This is indeed frustrating. We tried today to go live with a production and then run into one submodule that caused a complete break… this one. The breaking changes are indeed breaking. Can confirm that )))
This no longer works, and there seems no simple migration info? What is the replacement for Vue.locale ?
I had the same issue, and then I figured out that the version that npm installs is the 6.0.0-alpha. Why is put a alpha as the last version in npm repository?
I think is the main reason this issue is opened.
I mentioned in #148, Vue.config.lang is deprecated in v6 or later. And also In about
Vue.locale, it is deprecated in V6 or later. See the docs: https://kazupon.github.io/vue-i18n/en/migrations.html#vuelocale-replacedhas the same question in vue2
Same issue. Here is my main.js:
EDIT: Fixed by using the new init from 6.0.0-alpha1.