Vue-i18n: Strange warning messages 'Value of key '<<message>>' is not a string!'

Created on 30 Jul 2017  路  6Comments  路  Source: kazupon/vue-i18n

Vue version: 2.4.2
vue-i18n version: 7.0.5

Hello,

I'm using both global messages
const i18n = new VueI18n({ locale: getCurrentUserLanguage(), messages });
and local, component based messages:

i18n: {
    messages: {
      en: { msg: 'msg' },
      sk: { msg: 'msg' }
    }
  }

Everything works as expected.
But when I access global messages in the component that does have local, component-based messages, I get following warning:
image

I really don't like having bloated console, just to inform me about using fallback to global-translation.
And the warning message is kind of misleading.

Am I doing something wrong? If not, please consider removing this warning message for this particular use-case.

Thanks!

Most helpful comment

You can avoid with silentTranslationWarn.
https://kazupon.github.io/vue-i18n/en/api.html#vuei18n-class#silenttranslationwarn

All 6 comments

You can avoid with silentTranslationWarn.
https://kazupon.github.io/vue-i18n/en/api.html#vuei18n-class#silenttranslationwarn

Yep I added this:

export default new VueI18n({
  locale: 'en',
  silentTranslationWarn: process.env.NODE_ENV === 'production'
})

Maybe it's a good point to add this use case in the documentation for Component based localization

Here is the updated link for the specific option above.

That seems to work, but it's a workaround, because it also silences real errros, I believe. This becomes an issue particularly when actively debugging, when these "errors" mix with real translation errors and you lose sight.

Is it _wrong_ to access global translation on a Component based approach? If so, why?

Since 8.8 there is a silentFallbackWarn option that should better fit for people using Component based localization.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lucianobosco picture lucianobosco  路  4Comments

Brotzka picture Brotzka  路  4Comments

koslo picture koslo  路  5Comments

polikin picture polikin  路  4Comments

Rosadojonathan picture Rosadojonathan  路  4Comments