You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using i18n.mergeLocaleMessage, it is expected that keys that do not overlap entirely are preserved.
Fiddle to simulate the problem: https://jsfiddle.net/v6ec0mdx/
Given two objects with the same keys, if they have different child properties, the resulting object should be merged.
constmodule1={shared: {// key1 will be overwritten by mergeLocaleMessagekey1: 'I am part of a shared module, but spread accross translation files!'}}constmodule2={shared: {key2: 'I am an extension of a shared module!'}}i18n.mergeLocaleMessage('en',module1)// later in another file...i18n.mergeLocaleMessage('en',module2)// shared.key1 is lost
Suggestion
In i18n's src/index.js, instead of using Vue's extend method (check here), which does not preserve conflicting keys (or even deep checks conflicts), use i18n's utility merge method
The text was updated successfully, but these errors were encountered:
viniciuszani
changed the title
Merge locale messages should preserve 'deep' keys
Merge locale messages should preserve non-conflicting keys
Nov 6, 2018
Problem
When using
i18n.mergeLocaleMessage
, it is expected that keys that do not overlap entirely are preserved.Fiddle to simulate the problem: https://jsfiddle.net/v6ec0mdx/
Given two objects with the same keys, if they have different child properties, the resulting object should be merged.
Suggestion
In i18n's
src/index.js
, instead of using Vue'sextend
method (check here), which does not preserve conflicting keys (or even deep checks conflicts), use i18n's utility merge methodThe affected line is here:
vue-i18n/src/index.js
Line 463 in dc48099
The text was updated successfully, but these errors were encountered: