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

Add I18N support to scaffolded Gutenberg block #141

Closed
swissspidy opened this issue Apr 15, 2018 · 2 comments
Closed

Add I18N support to scaffolded Gutenberg block #141

swissspidy opened this issue Apr 15, 2018 · 2 comments

Comments

@swissspidy
Copy link
Member

While working on https://github.com/swissspidy/gutenberg-i18n-block I realized that even though the generated block uses wp.i18n, it can't be translated.

The I18N part of Gutenberg is pretty much in flux and not really documented. Nevertheless, I think we should enhance a scaffolded block so people don't have to worry about internationalisation — or at least point them into the right direction.

This includes:

  • Not using __() in the save callback as that doesn't work.
  • Using @wordpress/babel-plugin-makepot to create a POT file of all translatable strings.
  • Using wp_add_inline_script() and gutenberg_get_jed_locale_data() to load the translations.
  • Ideally: using pot-to-php or something similar to get a POT file that creates both the translatable strings from the JS, as well as from the PHP side of things.
@schlessera
Copy link
Member

@swissspidy Are there issues that we should still take care of here before WP 5.0?

@swissspidy
Copy link
Member Author

For WP 5.0 compatibility https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/ is of relevance.

We could still use wp_get_jed_locale_data(), but wp_set_script_translations() is probably superior. There's a lack of documentation though.

I plan on updating https://github.com/swissspidy/gutenberg-i18n-block soon with newer examples. This could help with updating the scaffold command as well.

@swissspidy swissspidy closed this as not planned Won't fix, can't repro, duplicate, stale Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants