[wp-trac] [WordPress Trac] #50732: Block Directory: Support installing blocks in languages other than English
WordPress Trac
noreply at wordpress.org
Wed Jul 22 00:30:19 UTC 2020
#50732: Block Directory: Support installing blocks in languages other than English
--------------------------+---------------------
Reporter: ryelle | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.5
Component: Editor | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+---------------------
Comment (by ryelle):
One solution is to call `setLocaleData` in the JS that loads the block
assets. We would also need the json translation content to pass in here
for each JS file (probably generated on the WP.org side), and passed
through the REST API. Then we could add something like this to the
`loadScript` for each asset — assuming `url` is the URL to the respective
json translation file, and that we have the text domain (also needed from
the API).
{{{
const translations = await apiFetch( { url } );
const localeData =
translations.locale_data[ domain ] ||
translations.locale_data.messages;
localeData[ '' ].domain = domain;
setLocaleData( localeData, domain );
}}}
I can work on a PR tomorrow morning (US), if this sounds like a path
forward.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50732#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list