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

DS-751: Add support for placeholders to Bolt-only version of |t filter #2458

Merged
merged 1 commit into from Mar 28, 2022

Conversation

remydenton
Copy link
Collaborator

Jira

https://pegadigitalit.atlassian.net/browse/DS-751

Summary

Adds support for placeholders in translatable strings

Details

Proper string translation requires the ability to use variables. For example, if you wanted to translate the string "Tom's Profile", where "Tom" was a variable that corresponded to the user's name, you couldn't just expect a translator to convert "'s profile" into, say, Spanish.

Instead, you should ask the translator to translate "@user's profile". A Spanish translator could then understand the context of what they were translating and rearrange the words to "Perfil de @user".

This PR adds support for basic placeholders in translated strings in Bolt to match how the Drupal |t filter already works in Drupal. See https://www.drupal.org/docs/theming-drupal/twig-in-drupal/filters-modifying-variables-in-twig-templates#s-translation-filters for more details

How to test

To test, you could create a string that contains a placeholder variable and confirm that it's output correctly. An example is shown in 4c868ea, so you could confirm that it's working as expected on that PR.

Copy link
Contributor

@colbytcook colbytcook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, confirmed that this method both on the Video Thumbnail twig and my own investigation

@colbytcook colbytcook merged commit d67e47f into master Mar 28, 2022
@colbytcook colbytcook deleted the feature/DS-751-support-translation-placeholders branch March 28, 2022 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature List this PR in the 'Features' section of the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants