Skip Navigation

Resolved

Resolved in: 4.2.0

Overview of the issue

Update 13/08/2020:

Since WPML 4.2.0, the JavaScript translation files (JED) are imported and the translations can be adjusted. WPML is creating its own JED files with custom translations.

We have attempted to implement the string scanning feature in JS files, but we gave up for technical limitations:
– Each string should be attached to the loaded JS file.
– The loaded file is usually a compiled file (i.e. babel / webpack) in which strings cannot be detected properly.
– Even if we could ever link the compiled file to the source files, those source files are usually excluded from plugins/themes released versions so it would be useless for most users.

If you build themes or plugins with strings in JS files, we recommend to build a POT file while compiling the JS script (see also https://developer.wordpress.org/block-editor/developers/internationalization/#provide-your-own-translations).

WordPress Block (“Gutenberg”) editor comes with a new strategy for string translation. It’s now possible to translate a string inside a JavaScript function. The consequence of this new feature is that all strings of the related script need to be loaded on the browser side. This is not compliant with the current WPML strategy to scan and filter the translations.

As the Block editor code is evolving quickly, we decided to wait until it’s merged into WordPress, and with a clear and stable API. Meanwhile, all the string translations in the Block editor will be loaded through the standard WordPress API regardless of WPML localization settings. Because of this, the Block editor strings will not be translated using WPML String Translation.

This should not affect the user experience too much since this new feature is only used in the backend (Block editor) and it is already significantly translated by the community.

Workaround

5 Responses to “Issue with string translation inside WordPress Block ("Gutenberg") editor”

  1. Would be nice to see a JS solution sooner rather than later, as I’d like to use string translation on Gutenberg blocks I wrote myself. Thanks.

    • Hi @martinS-123,

      We are working to support this feature, but the WordPress API is still evolving and some new filters (which are required) are planned for after WP 5.0.0.

      We’ll keep you updated as soon as possible.

      Thanks,
      Pierre

    • Hi @martinS-123,

      I updated the description of this errata and marked it as “resolved”.

      As you can see, we gave up trying to scan strings in JS files because of the technical limitations I mentioned.

      However, since WPML 4.2.0, we made it possible to import native JED files and adjust the native translations.

  2. Hi, this is just to inform you that since WPML 4.2.0, the JS translation files (JED) are imported and the translations can be adjusted. WPML is creating its own JED files with custom translations. However, we are now working on a solution to scan strings inside JS files.