'How to show dynamic data in internationalization react i18n
Hey guys I have a question regarding react i18n. I have a scenario where I'm translating like this
const context = history?.actionData?.status ||
history?.context ||
history.action ||
"N/A";
t("action-history-description", {...history, context)
and the action-history-description string looks like this
"{{context}} - ({{actionData.user.name}} - {{actionData.user.phone"
What I want to do is move the context condition inside the string. so the string should look like this
"{{actionData.status || context || action || 'N/A'}} - ({{actionData.user.name}} - {{actionData.user.phone"
and then i18n does the rest of the job. So if I have the actionData.status its value is shown. If not then context and so on. Is there any way to do this?
Solution 1:[1]
No, this is not possible. btw: the context feature of i18next works differently: https://www.i18next.com/translation-function/context
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | adrai |
