-
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
Global Styles: Use context when translating entries in theme.json #28246
Conversation
lib/class-wp-theme-json-resolver.php
Outdated
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain | ||
$item_to_translate[ $translatable_key ] = translate( $item_to_translate[ $translatable_key ], $domain ); | ||
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralContext,WordPress.WP.I18n.NonSingularStringLiteralDomain | ||
$item_to_translate[ $translatable_key ] = translate_with_gettext_context( $item_to_translate[ $translatable_key ], sprintf( 'theme %s %s', $path, $translatable_key ), $domain ); |
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.
I haven't try to execute it yet. I'm more flagging this issue that wasn't addressed in the original PR.
@jorgefilipecosta, any recommendations on how to compute the context name based on the path?
Could you provide some examples of the expected contexts? |
I was hoping that @jorgefilipecosta will do in the last minutes before he goes on the second part of his parental leave 😆 |
Size Change: 0 B Total Size: 1.37 MB ℹ️ View Unchanged
|
I guess we can add the contexts to file lib/experimental-i18n-theme.json.
Into something like:
|
Hey, I wanted to share that I'm working on making |
👋 I'm looking at this in the context of #27506 so I'm going to push any commits directly if that's ok. First step: load my brain with the past conversations about this. |
dbe6b90
to
9d6b04e
Compare
@swissspidy @aristath This is ready for review. Going to make #28783 work based on these changes. |
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.
Nice work @nosolosw. 👍
This PR attaches a translation context to the strings defined in
experimental-theme.json
, following the conversations atblock.json
– Blocks: Add i18n support to register_block_type_from_metadata wordpress-develop#868 (comment)theme.json
– Add theme.json i18n mechanism and JSON file specifying which theme.json paths are translatable #27380 (comment)It uses an auxiliary structure defined #28246 (comment) to know which data should be translated.
How to test