Skip to content
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

Use i18n schema for block.json from WordPress Core #287

Closed
1 task done
gziolo opened this issue Oct 14, 2021 · 5 comments · Fixed by #319
Closed
1 task done

Use i18n schema for block.json from WordPress Core #287

gziolo opened this issue Oct 14, 2021 · 5 comments · Fixed by #319

Comments

@gziolo
Copy link
Contributor

gziolo commented Oct 14, 2021

Feature Request

Describe your use case and the problem you are facing

BlockExtractor is using a hardcoded list of fields to translate from block.json file:

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:

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.

@swissspidy
Copy link
Member

Related question:

Since https://schemas.wp.org/trunk/theme.json is now a thing apparently, any plans on making the the i18n schemas available there as well?

@gziolo
Copy link
Contributor Author

gziolo commented Feb 5, 2022

Sure. It uses similar URL now:

https://schemas.wp.org/trunk/block.json

Wait, for i18n. Yes, that would be great 👍

@swissspidy
Copy link
Member

Who could set up these URLs?

@gziolo
Copy link
Contributor Author

gziolo commented May 4, 2022

Who could set up these URLs?

I see the URL got updated by @mkaz in WordPress/gutenberg#36316, but I don't know who set them up. I can't see any reference in Meta WordPress Trac, too.

@mkaz
Copy link

mkaz commented May 5, 2022

@gziolo @swissspidy You can make the request on Systems blog.

Here's the requests I made for the schemas:
https://make.wordpress.org/systems/2021/11/03/redirects-for-json-schemas/

💛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants