wrong behaviour when using replacements with same starting name
Opened this issue · 3 comments
sebsobseb commented
I have a translation message like this:
'items_from_to' => ':from - :to of :total'
When translating...
Lang.get('items_from_to', {
from: 1,
to: 10,
total: 34
})
I see:
1 - 10 of 10tal
instead of
1 - 10 of 100
sebsobseb commented
A solution would be to use \b in the regex:
new RegExp(':' + replacementName + '\\b', 'g'),
bytestream commented
Laravel sorts by length before doing the replacements - https://github.com/laravel/framework/blob/v7.0.0/src/Illuminate/Translation/Translator.php#L217
sebsobseb commented
Laravel sorts by length before doing the replacements - https://github.com/laravel/framework/blob/v7.0.0/src/Illuminate/Translation/Translator.php#L217
That's even better