Vue-i18n: global translations not reactive when component translations present

Created on 13 Jun 2018  路  6Comments  路  Source: kazupon/vue-i18n

vue & vue-i18n version

ex: 2.5.16, master

Reproduction Link

http://jsfiddle.net/qegsr2pn/40/
just switch between the two languages

Steps to reproduce

  • add some global translations and some translations in a component
  • change $i18n.locale on the fly

What is Expected?

global translations should be reactive

What is actually happening?

global translations are not reactive (the translation is correctly done on "boot")

(btw the link for vuejs in the jsfiddle is broken ; the jsfiddle described in a new issue comment)

Most helpful comment

You can change root locale the below:

<select v-model="$root.$i18n.locale">

All 6 comments

This is specification of component based localization.
See the docs

As in the example above, if the component doesn't have the locale message, it falls back to globally defined localization info. The component uses the language set in the root instance (in the above example: locale: 'ja').
If you hope localize in the component locale, you can realize with sync: false and locale in i18n option.

If it is an expected behavior, then please give us a way to get reactive global translations

Ex : a new method like $tg('global.message') (which would only use global translations, and would be reactive)

You can change root locale the below:

<select v-model="$root.$i18n.locale">

interesting

so it was just a "scope" problem, thanks

Suggest adding this to the docs.

@goldengecko
You can send PR :)
anytime, welcome

Was this page helpful?
0 / 5 - 0 ratings

Related issues

qiaochangwei picture qiaochangwei  路  16Comments

tvld picture tvld  路  19Comments

GregPeden picture GregPeden  路  39Comments

leo108 picture leo108  路  15Comments

Mrkisha picture Mrkisha  路  29Comments