Skip to content
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

Support markup in translated strings #1578

Closed
swissspidy opened this issue May 6, 2020 · 5 comments · Fixed by #4834
Closed

Support markup in translated strings #1578

swissspidy opened this issue May 6, 2020 · 5 comments · Fixed by #4834
Assignees
Labels
Internationalization (I18N) P1 High priority, must do soon Type: Enhancement New feature or improvement of an existing feature

Comments

@swissspidy
Copy link
Collaborator

swissspidy commented May 6, 2020

Feature Description

In #1473 we are removing usage of createInterpolateElement from the @wordpress/element package for good, as we can't rely on it being available / provided to us by WordPress (see #1374). We can also not include the package in our final bundle due to licensing.

That means, if we want to use markup in translated / internationalized strings, we need to come up with our own solution.

Right now, due to this limitation, we cannot do things like this:

__('All data are treated in accordance with <a href="...">Google Privacy Policy</a>.', 'web-stories')

or this:

__('Jump into the <Link href="...">editor</Link>.', 'web-stories')

Instead, we currently have to do workarounds like this:

{
  /* translators: First half of "Jump into the Editor" */
  _x('Jump into the', 'plugin activation', 'web-stories')
}
{' '}
<Link href={newStoryURL} onClick={onClick}>
  {__('Editor', 'web-stories')}
</Link>

But concatenating strings like this is bad for translators.

For reference, with createInterpolateElement it would look like this:

createInterpolateElement(
  __('Jump into the <a>editor</a>.', 'web-stories'),
  {
    a: <Link href={newStoryURL} onClick={onClick}>
  }
)

Additional Context


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance Criteria

QA Instructions

@barklund
Copy link
Contributor

barklund commented Oct 4, 2020

Now that we have some actual translators working on the translation, this issue crops up a lot.

@o-fernandez, we should really prioritize this one, even though we don't actually know how to solve it yet.

@swissspidy
Copy link
Collaborator Author

Now that we have some actual translators working on the translation, this issue crops up a lot.

There are now also a lot more places in the code base where we'd need something like this.


Added some more details to the ticket description.

I feel like with html-react-parser it might be possible to fix this for 1.1.0

@o-fernandez
Copy link
Contributor

Ok, would be good to see if a pod can take it up in this sprint, let's see how it goes in our sprint kickoff today.

@o-fernandez o-fernandez added P1 High priority, must do soon and removed P2 Should do soon labels Oct 5, 2020
@swissspidy
Copy link
Collaborator Author

I have a small proof-of-concept ready for this.

@swissspidy swissspidy self-assigned this Oct 7, 2020
@swissspidy swissspidy added this to the Sprint 39 milestone Oct 7, 2020
@swissspidy swissspidy reopened this Oct 9, 2020
@swissspidy
Copy link
Collaborator Author

Reopening because of these warnings:

Screenshot 2020-10-09 at 19 16 23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internationalization (I18N) P1 High priority, must do soon Type: Enhancement New feature or improvement of an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants