dkfbasel / vuex-i18n

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

Fix variable substitution matching #102

Closed MaxGfeller closed 5 years ago

MaxGfeller commented 5 years ago

Previously it would only match if the name for a variable was at least two characters long, due to the \w and . identifiers. This solution will also match dots that could be in the identifier - although i'm not sure if that's correct.

davidpelayo commented 5 years ago

Related with #104?

MaxGfeller commented 5 years ago

@davidpelayo Looks like it! Does this solution work for you? I only realized that we're getting problems with variables that were only one character long.

tikiatua commented 5 years ago

Hi @MaxGfeller

Thank you for the pull request. We actually put the word-character matcher there on purpose as it seems somewhat strange to have key identifiers that start with a character outside the range of [A-Za-z0-9_].

It will also more in line with the previous matching pattern, therefore hopefully not breaking to many things.

MaxGfeller commented 5 years ago

@tikiatua That makes sense. But this new rule actually sets a new requirement of two characters for a variable, which seems strange to me.

Many of our variables are just single-digit numbers (as generated so by vue-translation-manager and those don't work anymore.

tikiatua commented 5 years ago

Very good point. I will adapt the regex matcher to also match single characters that match [A-Za-z0-9_]

MaxGfeller commented 5 years ago

Sweet, thank you! And merry christmas to you and your family :)

tikiatua commented 5 years ago

Should be incorporated v1.10.9. However the regex is adapted slightly different, to only allow word characters (\w) if the length of the replacement is only one character, i.e. {0}