Translate pattern metadata (title & description)#40047
Merged
Conversation
oandregal
commented
Apr 5, 2022
youknowriad
reviewed
Apr 5, 2022
Member
Author
|
@mcsf @youknowriad @swissspidy I've addressed all the feedback and this is now ready. |
mcsf
approved these changes
Apr 5, 2022
Contributor
mcsf
left a comment
There was a problem hiding this comment.
Looks good as far as the original functionality is concerned (thanks for taking care of this!). A separate 👍 on the translation technique would be good.
Member
Author
|
Given the time-sensitive period we're in, I'm going to take this comment by Pascal as an "approval for direction" in terms of translation. It's also the same approach we follow to translate strings coming from theme.json (see). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related wp-cli/i18n-command#312
What?
#36751 introduced the ability to automatically register patterns from the
/patternsdirectory of the theme. This PR enables translation for the title & description of the pattern.Why?
Users expect patterns metadata to be translated.
How?
This PR uses
translate_with_gettext_contextto pull the strings provided by the theme in the correct user locale before the pattern is registered.Testing Instructions
1 - Create the pattern
patterns/my-test-heading.php:2 - Provide a translation
wp-content/languages/themes/.Alternatively, you can create the .mo file yourself for any language, here's how:
wp-content/languages/themes/and paste the following at the end of thetwentytwentytwo-es_ES.pofile:wp i18n make-mo <path-to-your-po-file> <path-to-the-directory>command to convert the.pofile into the.moone in the same directory.3 - Do the testing