ttag-org / ttag

:orange_book: simple approach for javascript localization
https://ttag.js.org/
MIT License
338 stars 41 forks source link

t,jt functions don't translate phrases where one variable uses several times #212

Closed oknesar closed 10 months ago

oknesar commented 3 years ago

I have two phrases image both of them are translated image but 2nd(where I use br twice) doesn't get a translation image

the problem is here https://github.com/ttag-org/ttag/blob/811efc38fa31e63d58c3978c1a96a6cedb728907/src/utils.js#L89 image because of the variable used twice, it overwrites into variableNumberMap object

ooaeoaii commented 3 years ago

I recently faced with same problem when I have repeating vars in one sentence and I really don't want to cut it into two parts!

Ex:

t`some text ${var} some text ${var}`

I fixed it like this but it looks too ugly:

const var2 = var;
t`some text ${var} some text ${var2}`

Bumping this issue

kevinlul commented 2 years ago

~I just encountered this bug as well. I wonder what the root cause is?~ Nevermind, just found the fixing #248... almost two months