-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Translate pattern metadata (title & description) #40047
Conversation
@mcsf @youknowriad @swissspidy I've addressed all the feedback and this is now ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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). |
Related wp-cli/i18n-command#312
What?
#36751 introduced the ability to automatically register patterns from the
/patterns
directory 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_context
to 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.po
file:wp i18n make-mo <path-to-your-po-file> <path-to-the-directory>
command to convert the.po
file into the.mo
one in the same directory.3 - Do the testing