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
At the company I'm working at, we're using key fallback for all of our translations as this allows us to keep the strings inside the code. We're also using the pluralize library to allow us to leave our English resource file empty.
Here's an example using t:
t('You have {{count}} message',{
count,defaultValue: `You have ${count}${pluralize('message',count)}`,});
The above works fine with t, but does not work with the Trans component since the key defaults to the defaults prop.
To Reproduce
<Transcount={count}defaults={`You have ${count}${pluralize('message',count)}`}>Youhave{{count}}message</Trans>
Expected behavior
I expect the key to be You have {{count}} message, but the key that react-i18next uses in the t call is You have 3 messages (if count is 3, for example).
Proposed solutions
(breaking change) Rather than defaulting the key to the defaults prop here, default to nodesToString(children, reactI18nextOptions).
Add a defaultValue prop that behaves similar to the one in t (i.e. does not get used as the key).
I can open a PR for this if we decide on a solution.
The text was updated successfully, but these errors were encountered:
馃悰 Bug Report
At the company I'm working at, we're using key fallback for all of our translations as this allows us to keep the strings inside the code. We're also using the pluralize library to allow us to leave our English resource file empty.
Here's an example using
t
:The above works fine with
t
, but does not work with the Trans component since the key defaults to thedefaults
prop.To Reproduce
Expected behavior
I expect the key to be
You have {{count}} message
, but the key that react-i18next uses in thet
call isYou have 3 messages
(ifcount
is 3, for example).Proposed solutions
defaults
prop here, default tonodesToString(children, reactI18nextOptions)
.defaultValue
prop that behaves similar to the one int
(i.e. does not get used as the key).I can open a PR for this if we decide on a solution.
The text was updated successfully, but these errors were encountered: