Global Styles: Use context when translating entries in theme.json - #28246
Conversation
| // 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.
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. |
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