Andrelec1
Andrelec1

Reputation: 382

Vue-js Vue-i18n dictionnay seem not loaded

I try to intertionalise my app, i use vue-i18n...

in my app.js i have this :

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

import App from './App';

Vue.use(VueI18n);

const messages = {
  en: {
    message: {
      hello: 'hello world',
    },
    hello: 'hello world',
  },
};

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

/* eslint-disable no-new */
new Vue({
  el: '#app',
  i18n,
  router,
  template: '<App/>',
  components: { App },
  render: h => h(App),
});

and in child of child of ... component i try to do a simple :

`this.$t('hello');`

But always have : [vue-i18n] Cannot translate the value of keypath 'hello'. Use the value of keypath as default.

So i think i missconfig some thing but i can't found why !!

Upvotes: 1

Views: 1240

Answers (1)

samayo
samayo

Reputation: 16495

You have a typo in local, it should be locale (you forgot the e)

So, do this:

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

Upvotes: 1

Related Questions