dkfbasel / vuex-i18n

Localization plugin for vue.js 2.0 using vuex as store
MIT License
666 stars 56 forks source link

The v1.10.7 introduced a couple of breaking changes: Comparison vs v1.10.5 #104

Closed davidpelayo closed 5 years ago

davidpelayo commented 5 years ago

I'm checking the differences of the v1.10.5 and v1.10.7 due I had translations using multiple placeholders that they were getting translated correctly before, and after upgrading they fail.

The comparison link, between those two versions, is the following: https://github.com/dkfbasel/vuex-i18n/compare/v1.10.5...v1.10.7.

So, were before this was correctly working:

computedProp() {
  const quantityClassName = this.$style[`${this.mainClassname}__quantity`];
  const translationParameters = {
    0: `<span id="${this.fromId}" class="${quantityClassName}">${from}</span>`,
    1: `<span id="${this.toId}" class="${quantityClassName}">${to}</span>`,
    2: `<span id="${this.totalId}" class="${quantityClassName}">${total}</span>`,
  };

  return this.$t(resultInfoKey, translationParameters);
}

With the version v1.10.7 returns the following

screen shot 2018-12-24 at 10 18 14 am

Not all placeholders found.

And I'm starting to suspect the root cause of this issue is at this line of code. Which actually relates to #98 and #99.

Please, any feedback or fix, is welcome.

tikiatua commented 5 years ago

HI @davidpelayo,

This issue is quite likely due to the changed regular expression match that we use to identify placeholders in translation strings. With the new regex matcher, we require at least two characters, which breaks your code if the variable replacement results in a matcher with only one character (i.e. a number).

I will adapt the regex matcher to also include matches for single characters as long as they match [A-Za-z0-9_]. Stay tuned.

tikiatua commented 5 years ago

should be fixed in latest release v1.10.9

davidpelayo commented 5 years ago

Additionally, to my message above, the latest version fails on IE11 due short hand properties not being transpiled, such us this.

Where:

SET_LOCALE(state, payload) {
}

It should be:

SET_LOCALE: function(state, payload) {
}

i18nerror

Is this intended?

tikiatua commented 5 years ago

Hi @davidpelayo

Thank you for reporting this. Definitely not intended. I will look into this.

tikiatua commented 5 years ago

Hi there,

The issue should be fixed now in version v1.10.10. I needed to change the build process somewhat, as babel needs the node_modules and babelrc file to be in the same root directory as the scripts to transpile.