DS-751: Add support for placeholders to Bolt-only version of |t filter #2458
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 detailsHow 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.