[feat] get message id in textComponent #2697
IcanDivideBy0
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
im not sure i fully understand your use case. Do u have an example/screenshot/running app of some sort? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
What do you think about sending the messageId to the
textComponent
given to the provider?I'm trying to make a in-place translations editor. I think this is totally possible by just droping a custom component in the
textComponent
provider prop, but this component don't have access to the message id.By default React.Fragment is used, but we can only pass the message id in case there is such a text copmponent defined (in fact there's already an
if
aroud this case https://github.com/formatjs/formatjs/blob/main/packages/react-intl/src/components/message.tsx#L61)Also the text component can be overriden at
FormattedMessage
level; to avaoid any problem with this maybe we can pass the id as a data prop (iedata-react-intl-message-id="XXXX"
), but this would bloat the html, another solution I can see is to have a flag in the provider to configure the Formattedmessage behavior so we can disable it if not needed (prod vs dev mode for example)If you think that would be interresting I can send a PR pretty quickly.
In any case if you have any idea/suggestion for a drop-in solution to translate string in-place, I'd like to hear about it :)
Beta Was this translation helpful? Give feedback.
All reactions