question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot read property 'locale' of undefined

See original GitHub issue

Hi.I use the vue-router with vue-i18n together,when i changed the path,chrome remind a issue image

my i18n.js

import Vue from 'vue'
import VueI18n from 'vue-i18n'
import cn from './zh-CN.json'
import jh from './zh-JH.json'
import store from '../store'

Vue.use(VueI18n)

export default new VueI18n({
  locale: 'zh-JH',
  messages: {
    'zh-CN': cn,
    'zh-JH': jh
  }
})

vue & vue-i18n version

```"vue": "^2.1.0",
"vue-i18n": "^6.0.0-alpha.2",
"vue-router": "^2.0.1",```

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:7
  • Comments:57 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
ChangJoo-Parkcommented, Mar 21, 2017

https://github.com/ChangJoo-Park/vue-i18n-error

Here is my repo

in the locales directory,

import Vue from 'vue'
import VueI18n from 'vue-i18n'

Vue.use(VueI18n)
Vue.config.lang = 'en'

const locales = {
  en: {
    message: {
      hello: 'hello world'
    }
  },
  ja: {
    message: {
      hello: 'こんにちは、世界'
    }
  },
  ko: {
    message: {
      hello: '안녕하세요'
    }
  }
}
// !!!: Vue-i18n은 vue-router 이전에 정의 되어 있어야함
// TODO: VueI18n 다른 파일로 이동
Object.keys(locales).forEach(lang => {
  Vue.locale(lang, locales[lang])
})

Error message

Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_1_vue__.default.locale is not a function
    at eval (eval at <anonymous> (http://localhost:8080/app.js:1142:1), <anonymous>:32:48)
    at Array.forEach (native)
    at eval (eval at <anonymous> (http://localhost:8080/app.js:1142:1), <anonymous>:31:84)
    at Object.<anonymous> (http://localhost:8080/app.js:1142:1)
    at __webpack_require__ (http://localhost:8080/app.js:660:30)
    at fn (http://localhost:8080/app.js:84:20)
    at eval (eval at <anonymous> (http://localhost:8080/app.js:1163:1), <anonymous>:2:67)
    at Object.<anonymous> (http://localhost:8080/app.js:1163:1)
    at __webpack_require__ (http://localhost:8080/app.js:660:30)
    at fn (http://localhost:8080/app.js:84:20)

Is this Webpack issue?

2reactions
h6ah4icommented, Mar 12, 2017

@kazupon Hi. I have successfully reproduced the bug thanks to @zce 's advice!

https://github.com/h6ah4i/vue-i18n-issue-118-sample

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'locales' of undefined - Stack Overflow
I have that. Cannot read property 'locales' of undefined. error when using select2-rails. It raises somewhere here. fn.select2.locales.ru.
Read more >
TypeError: Cannot read property 'locale' of undefined - Forums
Hi! I have a very simple Lambda function (with default and basic configuration) that is throwing the following error.
Read more >
Locale issue. Cannot read property 'replace' of undefined
We have been getting the above error and I am guessing it it because of the locale. What is the best way to...
Read more >
How to fix Vue I18n Uncaught TypeError - Our Code World
... I18n Uncaught TypeError: Cannot read property 'config' of undefined ... i18n = new VueI18n({ // set locale locale: 'en', // set locale ......
Read more >
Cannot set property 'locale' of undefined got when input Enter ...
TypeError : Cannot set property 'locale' of undefined got when input Enter directly in console. ... A clear and concise description of what...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found