Skip to content

Rich text formatting and translations #513

@geekyme

Description

@geekyme

Issue

Say i have a string:

To buy a shoe, 
<a class="external_link" target="_blank" href="https://www.shoe.com/">visit our website</a>
and
<strong class="important">eat a shoe</strong>

According to https://github.com/yahoo/react-intl/wiki/Components#formattedmessage, I need to format my text this way:

<FormattedMessage
    defaultMessage='To buy a shoe, { link } and { cta }'
    values={{
        link: <a class="external_link" target="_blank" href="https://www.shoe.com/">visit our website</a>,
        cta: <strong class="important">eat a shoe</strong>
    }}
/>

When doing string extraction with https://github.com/yahoo/babel-plugin-react-intl, I would get:

To buy a shoe, { link } and { cta } to be translated.

This isn't good because I lose the context and texts from the rich content for link and cta.

Suggestion

I think we should have some special delimiters to surround rich text content so translators can still translate the text as a whole:

To buy a shoe, @visit our website@ and @eat a shoe@

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions