How can I define context/gender for translation? #977
-
I need to translate strings differently depending on the gender and overall context of the variable. I see that in other, similar libs, it is done through a special context variable, e.g.:
So the translation files can do something like:
So similar to "count" special notation. It doesn't work with next-translate and I don't see anything in the docs. Is it possible? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Context is not implemented. Please confirm if you can solve using this way #611 (comment) One of the goals of the library is to keep tiny (~1kb), so we are only supporting the really necessary features. If you have some troubles with the solution that I proposed and you think that this feature is really necessary to implement, feel free to open an issue to report it to implement. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your quick answer! I actually was thinking about doing that before checking this thread back, and the solution you linked to works, but only partially: the problem is that I would need to exhaustively define a translation for each possible context value. The perfect "working workaround" is do add a fallback, so in my case:
This works like a charm! |
Beta Was this translation helpful? Give feedback.
Thanks for your quick answer! I actually was thinking about doing that before checking this thread back, and the solution you linked to works, but only partially: the problem is that I would need to exhaustively define a translation for each possible context value.
The perfect "working workaround" is do add a fallback, so in my case:
{ t("go_to_country_" + country_code.toLowerCase(), { name: country }, { fallback: 'go_to_country' }) }
This works like a charm!