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
Hello!, I'm currently working with the Lokalise service to get translations for multiple languages, they have this feature for plural values that returns a stringed object e.g.
{ "Day": "{\"one\":\"Day\",\"other\":\"Days\"}" }
And I want to reuse this translation in multiple places but the current approach for pluralization in react-intl doesn't allow me to do it, I have to define each paragraph with plural values included
"{count, plural, =0 {no items} one {# item} other {# items}}"
I was thinking of doing something like this:
constmessages=defineMessages({es: {"description": "llevará alrededor de {time, plural, one {{ one }} other {{ other }}","days": "{\"one\":\"Día\",\"other\":\"Días\"}"},en: {"description": "it may take about {time, plural, one {{ one }} other {{ other }}","days": "{\"one\":\"Day\",\"other\":\"Days\"}"},});constdays=JSON.parse(formatMessage(messages.days));formatMessage(messages.description,{time: 1, ...days})
I may be probably missing something here, but in my implementation it works, I mean it is just a parsed object, I just want to know if this is the correct approach to use keys as they come from lokalise
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello!, I'm currently working with the Lokalise service to get translations for multiple languages, they have this feature for plural values that returns a stringed object e.g.
And I want to reuse this translation in multiple places but the current approach for pluralization in react-intl doesn't allow me to do it, I have to define each paragraph with plural values included
"{count, plural, =0 {no items} one {# item} other {# items}}"
I was thinking of doing something like this:
I may be probably missing something here, but in my implementation it works, I mean it is just a parsed object, I just want to know if this is the correct approach to use keys as they come from lokalise
Beta Was this translation helpful? Give feedback.
All reactions