Problem/Motivation

Some strings in Gutenberg could not be translated because they contained malformed HTML. That should be fixed to make a great experience even more awesome.

Since we still don't have coding standards for this, Gutenberg is not the only project with this problem. With the new implementation of the localisation server, we have the chance to avoid such issues not only in Gutenberg. Original strings that can't be translated into other languages lead us to 3 things:

1. Such strings make life difficult for translators because they can't translate a project containing such a string.

2. Such strings degrade the quality of a project if it is to be used in languages other than English

3. Such strings frustrate users because they ensure that a significant project cannot be delivered 100 per cent in their native language.

Not only Gutenberg, but these are also three good reasons to eliminate such problems and avoid them from the outset in the future.

The strings affected by this issue are:

#2847427
#2847949
#2878775
#2878819

This is a test string we have to delete the translation for #2878818.
This one is using in its source string instead of
#2765475

Steps to reproduce

  1. Translate one of those strings on localize.drupal.org in any language
  2. Accept translations
  3. Wait for the server to render the file
  4. Install Drupal in the chosen language
  5. Install and enable Gutenberg as usual
  6. Check Locale Watchdog for error messages about malformed HTML being skipped while translation got imported

Proposed resolution

Make sure that only allowed HTML Tags are wrapped into t(). You can find a list of all allowed tags in t() here:

Brake up those HTML strings in parts, so they do not contain HTML Tags not allowed within t()

https://api.drupal.org/api/drupal/core%21modules%21locale%21locale.modul...

Remaining tasks

Change code
Update the issue when the code is changed in the next release so Translators know they can finish the Translation

User interface changes

Strings will be translatable in the feature

API changes

Data model changes

Comments

Joachim Namyslo created an issue. See original summary.

joachim namyslo’s picture

Issue summary: View changes
joachim namyslo’s picture

Parent issue: » #3329697: Gutenberg
joachim namyslo’s picture

Issue summary: View changes
joachim namyslo’s picture

Issue summary: View changes
joachim namyslo’s picture

Issue summary: View changes
joachim namyslo’s picture

Title: Malformed Translations need to be fixed » Fix malformed translation source strings
Issue summary: View changes
joachim namyslo’s picture

Issue summary: View changes
joachim namyslo’s picture

Title: Fix malformed translation source strings » Fix malformed HTML in source strings, please
Issue summary: View changes

Changed title and updated summary

joachim namyslo’s picture

Issue summary: View changes
meeni_dhobale’s picture

Not able to reproduce the issue on local. Didn't find any way to check the updated code on local language translation. Didn't understand how can I check my updated code is it translate those string or not.

joachim namyslo’s picture

In fact the only method I can think of is to generate a po file that contains translations to the new source strings. We have here in the community I believe the potx module for this purpose. I'm not sure about that though. I'll ask around.

joachim namyslo’s picture

Issue summary: View changes
gábor hojtsy’s picture

Yeah you can use potx module to generate the full translation template for the project (using drush or the UI) and then import it back. If the import say there were malformed HTML, then its not yet good enough. :) Hope that helps.

joachim namyslo’s picture

Here is the additional information Marco Fernandez provided on slack.

Hi! This will require some thought because those strings come from the Gutenberg library/package. So we need to figure out the best way to override it. My initial idea is to have some “middleware” to map some of the original Gutenberg translations to translations compatible with Drupal. Let’s see.
Maybe I’ll also try to reach out to Gutenberg core devs about the possibility of changing those strings on the library.

So if you have some Ideas at Frontkom on how to handle it, that would be great. I bet we will get that problem again as soon as Gutenberg's JS-Code updates. Maybe you have a solution already because the translation for the rest of the strings is possible. I learned that you can wrapü t() around js-code, too, but I am not sure that is possible in Gutenberg js-Fils.