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 translate the value of keypath 'message.welcome'. Use the value of keypath as default.

See original GitHub issue

vue & vue-i18n version

"vue": "^2.0.1",
"vue-i18n": "^7.3.2",

Reproduction Link

github: https://github.com/polikin/vuejs-boilerplate

Steps to reproduce

main.js

import Vue from 'vue';
import App from './App.vue';
import router from './router/index';
import i18n from './locale/index';

new Vue({
    el: '#app',
    template: '<App/>',
    components: { App },
    router,
    i18n
}).$mount('#app'); //mount the router on the app

locale/index.js

import Vue from 'vue';
import VueI18n from 'vue-i18n'
import messages from './message';

Vue.use(VueI18n)

const i18n = new VueI18n({
  locale: 'en',
  messages
});

locale/message.js

export default [
    {
        en: {
            message: {
                welcome: 'Welcome'
            }
        },
        fr: {
            message: {
                welcome: 'Bonjour'
            }
        }
    }
];

export default i18n;

What is Expected?

Hello.vue <p>{{ $t("message.welcome") }}</p> should render ‘Welcome’`

What is actually happening?

I get this error: vue-i18n.common.js:16 [vue-i18n] Cannot translate the value of keypath 'message.welcome'. Use the value of keypath as default.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:18
  • Comments:5

github_iconTop GitHub Comments

23reactions
Miguel-Herrerocommented, Oct 27, 2017

Hi @polikin I had this problem until I read this comment. My problem was that I renamed the messages property (exactly like in the comment). Renaming it made the thing work.

Maybe your problem is related with exporting the translations. I notice that you don’t export default i18n in your locale/index.jsand I’ve different messages file:

const messages = {
  en: {
    home: {
      someString: 'Una cadena de texto'
    }
  },
  es: {
    home: {
      someString: 'A string of text'
    }
  }
}

export default messages

Hope it helps! 😃

4reactions
DanielWaltherCodecommented, Jul 9, 2020

I experienced the same problem and in my case it was caused by referencing variables that were not available at page load. I used a variable I fetched from my API as a translation key and since this was not immediately available I got warning messages (but once the api call went through the string was translated correctly).

Adding a simple v-if to check if the variable was set got rid of the warning message.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue: vue-i18n: Cannot translate the value of keypath, Use the ...
Cannot translate the value of keypath 'NavbarMobile.home'. Use the value of keypath as default. I checked if the plugin is working by console....
Read more >
I18n - Cannot translate the value of keypath - Vue Forum
Hello everyone, I am using i18n for translations on my website. It was working fine till 6th October 2018, but I'm getting the...
Read more >
Cannot translate the value of keypath - Laracasts
Hi! Have this error on every place i set text app.js:32228 [vue-i18n] Cannot translate the value of keypath What is the problem ?...
Read more >
[vue-i18n] Cannot translate the value of keypath 'message ...
Dont know whats wrong gives me this error: [vue-i18n] Cannot translate the value of keypath 'message'. Use the value of keypath as default....
Read more >
[Solved]-vue-i18n Cannot translate the value of keypath-Vue.js
i) if (matched && matched.length > 1) { const locale = matched[1] messages[locale] = locales(key) } }) return messages } export default new...
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