Skip to content

FormattedMessage rich text replacements are not applied on build phase #121

Open
@ixzzd

Description

@ixzzd

Hello, thank you for the great plugin!

I found one corner case of FormattedMessage rich text feature usage. Rich text replacements applied on runtime, instead of build time. This could be critical for SEO optimization and for page loading speed.

For example you have FormattedMessage like:

<FormattedMessage id="textWithLink" values={{
  link1: msg => (
    <a href="https://github.com/wiziple/gatsby-plugin-intl" >
      {msg}
    </a>
 )}} />

And translation:

"textWithLink": "I am text, click on <link1>link</link1> to open it",

After build this line this line in index.html file looks like this :

I am text, click on &lt;link1&gt;link&lt;/link1&gt; to open it

But expected behavior is- render it fully on build time and looks like:

I am text, click on <a href="https://github.com/wiziple/gatsby-plugin-intl" >link</a> to open it

Here I made small reproduce repo:
https://github.com/ixzzd/gatsby-react-intl-formatted-message-repro

Steps to reproduce:

  • Run yarn build
  • Open public/en/index.html file
  • Search for "I am text" string

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions