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

A way to register custom blocks translations #4856

Closed
wants to merge 3 commits into from

Conversation

@willybahuaud
Copy link
Contributor

commented Feb 4, 2018

Description

The purpose of this update is to provide a way (for a plugin) to push its translations into Jed's data (at the same time as that of Gutenberg, because Jed can't switch between two localData).

It have to be used this way :

add_filter( 'gutenberg_get_third_party_translation_domains', 'add_my_plugin_blocks_textdomain' );
function add_my_plugin_blocks_textdomain( $domains ) {
	$domains[] = 'my-plugin-textdomain';
	return $domains;
}

I hesitated to propose a method like load_plugin_textdomain, but I think it's not a good idea to use another global ;-)

How Has This Been Tested?

I installed Gutenberg on a local WP instance, aside another plugin containing a block (and translated strings). Then I added the described add_filter into my plugin file and I verified that my translated strings appeared.

Types of changes

Just after getting Gutenberg text translations, and before set Jed Local Data, we request custom domains translations (using a filter hook), and add it to the data array.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code has proper inline documentation.
willybahuaud added 3 commits Feb 4, 2018
The purpose of this update is to provide a way (for a plugin) to push its translations into Jed's data (at the same time as that of Gutenberg, because Jed can't switch between two localData).

It have to be used this way :
```add_filter( 'gutenberg_get_third_party_translation_domains', 'add_my_plugin_blocks_textdomain' );
function add_my_plugin_blocks_textdomain( $domains ) {
	$domains[] = 'my-plugin-textdomain';
	return $domains;
}```

I hesitated to propose a method like `load_plugin_textdomain`, but I think it's not a good idea to use another global ;-)
Copy link
Contributor Author

left a comment

Delete an empty space and add an inline comment

@aduth aduth self-requested a review Feb 5, 2018
@aduth

This comment has been minimized.

Copy link
Member

commented Mar 8, 2018

@willybahuaud Can you check #5489 to see if it serves the needs you're trying to achieve here?

@aduth

This comment has been minimized.

Copy link
Member

commented Apr 2, 2018

Closed by #5489

@aduth aduth closed this Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.