-
Notifications
You must be signed in to change notification settings - Fork 59
Closed
Description
Feature Request
- Yes, I reviewed the contribution guidelines.
Describe your use case and the problem you are facing
BlockExtractor is using a hardcoded list of fields to translate from block.json file:
i18n-command/src/BlockExtractor.php
Lines 46 to 66 in ea8a6b3
| case 'title': | |
| case 'description': | |
| $translation = $translations->insert( sprintf( 'block %s', $key ), $original ); | |
| if ( $add_reference ) { | |
| $translation->addReference( $file ); | |
| } | |
| break; | |
| case 'keywords': | |
| if ( ! is_array( $original ) ) { | |
| continue 2; | |
| } | |
| foreach ( $original as $msg ) { | |
| $translation = $translations->insert( 'block keyword', $msg ); | |
| if ( $add_reference ) { | |
| $translation->addReference( $file ); | |
| } | |
| } | |
| break; | |
| case 'styles': |
Describe the solution you'd like
Replicate the approach used for ThemeJsonExtractor that uses schema for theme.json located in WordPress core codebsase:
i18n-command/src/ThemeJsonExtractor.php
Lines 106 to 125 in ea8a6b3
| private static function remote_get( $url ) { | |
| if ( ! $url ) { | |
| return ''; | |
| } | |
| $headers = [ 'Content-type: application/json' ]; | |
| $options = [ 'halt_on_error' => false ]; | |
| $response = Utils\http_request( 'GET', $url, null, $headers, $options ); | |
| if ( | |
| ! $response->success | |
| || 200 > (int) $response->status_code | |
| || 300 <= $response->status_code | |
| ) { | |
| WP_CLI::debug( "Failed to download from URL {$url}", 'make-pot' ); | |
| return ''; | |
| } | |
| return trim( $response->body ); | |
| } |
The schema for block.json is located at https://github.com/WordPress/wordpress-develop/blob/master/src/wp-includes/block-i18n.json.
Reactions are currently unavailable