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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/i18n.php
Expand Up @@ -41,6 +41,23 @@ function gutenberg_get_jed_locale_data( $domain ) {
$locale['locale_data'][ $domain ][ $msgid ] = $entry->translations;
}

/*
* Get Third Party textdomains to add custom translation to Jed local data
*/
$third_party_translation_domains = apply_filters( 'gutenberg_get_third_party_translation_domains', array() );
if ( ! empty( $third_party_translation_domains ) ) {
foreach ( $third_party_translation_domains as $third_party_domain ) {
$translations = get_translations_for_domain( $third_party_domain );
if ( ! $translations ) {
continue;
}
foreach ( $translations->entries as $msgid => $entry ) {
$locale['locale_data'][ $domain ][ $msgid ] = $entry->translations;
$locale['locale_data'][ $domain ]['domain'] = $third_party_domain;
}
}
}

return $locale;
}

Expand Down