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.

[vue-i18n] Cannot translate the value of keypath...

See original GitHub issue

vue & vue-i18n version

ex: 2.0.0-beta.3, 4.1.0

Steps to reproduce

// main.js

import Vue          from 'vue'
import VueResource  from 'vue-resource'
import VueI18n      from 'vue-i18n'
import router       from './router/routes.js'
import App          from './App'

// =======================
// Store
// =======================
Vue.use(VueResource)

// =======================
// Localization
// =======================
Vue.use(VueI18n)

// let self = this
const lang = 'de'

Vue.locale(lang, function () {
  // self.loading = true
  return fetch('../static/lang_' + lang + '.json', {
    method: 'get',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    }
  }).then(function (res) {
    return res.json()
  }).then(function (json) {
    // self.loading = false
    if (Object.keys(json).length === 0) {
      return Promise.reject(new Error('locale empty !!'))
    } else {
      return Promise.resolve(json)
    }
  }).catch(function (error) {
    // self.error = error.message
    console.error(error.message)
    return Promise.reject()
  })
}, function () {
  Vue.config.lang = lang
})

/* eslint-disable no-new */
new Vue({
  router,
  render: h => h(App),
  http: {
    root: '/root',
    headers: {
      Authorization: 'Basic YXBpOnBhc3N3b3Jk'
    }
  }
}).$mount('app')
//lang_de.json

{
  "apptitle": "App erstellen",
  "headnav": {
    "help": "Hilfe / FAQ",
    "register": "Registrieren",
    "login": "Anmelden"
  }
}
// Template
<template lang="pug">
  header.brandbar
      h1.brand__title {{ $t("apptitle") }}
</template>

What is Expected?

No warnings 😃

What is actually happening?

I try to use your plugin with webpack and vue, and it does what it says - apptitle is rendered as App erstellen, but i get annoying console-warnings:

[vue-i18n] Cannot translate the value of keypath "apptitle". Use the value of keypath as default

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kazuponcommented, Aug 7, 2016

Hmm. I think that we can resolve with using callback of Vue.locale and v-cloak. e.g. http://jsfiddle.net/kazupon/Lh980stL/8/

1reaction
Frozirecommented, Aug 5, 2016

Yeah - just a bit problematic when you have a lot of other dependencies that further delays when you can instantiate vue app instance.

I would much prefer if we could set a variable like “hasLoadedTranslations” on the instance and only then will translations be set.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue: vue-i18n: Cannot translate the value of keypath, Use ...
I am using Vue, and I want to show three languages. English, Tagalog and Cebuano. Now I have the error. Cannot translate the...
Read more >
Cannot translate the value of keypath 'message.welcome'. ...
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 ...
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
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'. ...
[vue-i18n] Cannot translate the value of keypath 'message'. Use the value of keypath as default. #1150. jackDani16 posted onGitHub.
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