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.

SFC and Cannot translate the value of keypath...

See original GitHub issue

This is not exactly an issue of vue-i18n-loader, I am writing it as a reminder for others that may face this problem: if, inside a single file component, you get the error “Cannot translate the value of keypath…”, it may be cause by npm cache.

Solution:

  • Check, double check that your vue-i18n-loader has been properly configured
  • Add a syntax error inside the <i18n>{...}</i18n> tag
  • Check that webpack does not compile because the loader complains about the syntax error (if it doesn’t, than you didn’t configure properly the vue-i18n-loader inside webpack config file)
  • Remove the syntax error
  • Remove node_modules folder (the whole folder, not just the i18n folders)
  • run npm cache clean
  • run npm install

After that, it worked for me (and my colleagues facing the same problem).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Koutycommented, Jul 18, 2017

Indeed there is.

...
</template>

<i18n src="./i18n.json"></i18n>

<script>
...
2reactions
TugayYaldizcommented, Aug 9, 2018

As @Kouty 's say; you need to change root component’s $i18n. So there is $root instance property (which reach to the App.vue) available in every component or sub component in your Vue instance. İnstead of changing this.$i18n.locale you can change this.$root.$i18n.locale = newVal in template tags just $root.$i18n.locale = newVal.

No need to emiting events, watching props etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue-i18n Cannot translate the value of keypath - Stack Overflow
I cannot get the translations to work every single one get the Cannot translate the value of keypath. the config looks like this...
Read more >
Storybook + Vuejs + vue-18n : translate strings from sfc i18n ...
Storybook + Vuejs + vue-18n : translate strings from sfc i18n section but not root messages ... [vue-i18n] Cannot translate the value of...
Read more >
<i18n> in TypeScript SFC not able to translate value - Get Help
Almost. The first message about the key not being a string is gone. Now this remains: [vue-i18n] Cannot translate the value of keypath...
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 >
Breaking Changes - Vue I18n
Similar to Translation API return value, the pluralization API like ... In Vue I18n v9 or later, you can't use array-like objects for...
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