-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Links and other tags in messages #68
Comments
@gpbl In the soon-to-finished const message = 'Visit <a href="https://github.com">github</a> now!';
<p><FormattedHTMLMessage message={message} /></p> That said, the way we have to implement the const message = 'Visit {link} now!';
<p>
<FormattedMessage
message={message}
link={<a href="https://github.com">github</a>} />
</p> This removes the HTML from the static message string and moves it into JSX land where both the This stuff is available right now on
|
Awesome, I had not even thought to pass The |
Awesome to hear! Yeah we just added support for being able to pass React Elements as prop values when formatting messages: #65 (comment) I'm working on updating the docs for the site now and we'll add an example of doing this so people are aware that it's possible. |
@ericf I just ran into this similar issue as well and I realized that while we can write It will be useful to have the entire Ref: #89 |
Is there a way to translate what's inside 'link' ? |
I ended up doing something like this:
with my HELP_PREVIEW_6 string containing something like
|
Just to throw my $0.02 in here, I needed a way to put a link around individual words in the source bundles, but couldn't rely on an english-only token to look for so came up with:
and the usage is:
in case anyone else finds it useful. |
Awesome, just what I was looking for. Thanks a lot, it works like a charm. |
@phiggins42 it's an interesting approach, but I don't see where you make Ideally we would have something like that standardized: <FormattedMessage
id="some.text.with.link"
defaultMessage="Click {url|`on this link`} to read more."
values={{
url: localizedUrl,
}}
/>
Note: I'm using the backtick as a safeguard in case we need quotes. |
We already support rich text natively |
How would you deal with messages containing tags, e.g. links?
For example this can't be rendered by React:
A solution is that in use by khan academy. Then I would write something like:
I wonder how are other developers solving this case? Could react-intl help with it?
The text was updated successfully, but these errors were encountered: