The slick.optionset configuration add prevArrow and nextArrow settings, which according to the slick settings documentations shall contain html like <button type="button" data-role="none" class="slick-prev" aria-label="Previous" tabindex="0">Previous</button>.

Unfortunately drupal passes configuration through t() / TranslatableMarkup(), therefore creating strings in translation containing disallowed html, see Drupal API for a list of allowed html tags.

The offending strings can be seen in german translations for example, but it is the same for all languages. Strings containing <button> will fail to import.

Comments

volkerk created an issue. See original summary.

gausarts’s picture

Status: Active » Postponed (maintainer needs more info)

Thank you! Do you have any suggestion?

volkerk’s picture

Well, is it really necessary to be able to replace the html tag through configuration?

Maybe it would be sufficient to set the button labels in config and add the button markup via Drupal.theme javascript function.

Drupal.theme.slickNavButton = function(options) {
  return '<button type="button" data-role="none" class="slick-prev" aria-label="' + options.label +'" tabindex="0">' + options.label + '</button>';
};
gausarts’s picture

Good idea, thank you!

Well, is it really necessary to be able to replace the html tag through configuration?

No really. I didn't want to think much about the needs last time. It was there simply because it is an option ;)

There was one option I excluded due to its trivial usage, IIRC, and then later a user proposed a patch to include it. So as you see, options should always be available as options.

What bothered me is how to handle existing users with their own custom HTML markups, says with A tag, and additional classes or attributes?
It is not only about texts: Previous + Next.
It is also hardcoded in TWIG, so perhaps it is better to go in there rather than JS version?

gausarts’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
Status: Postponed (maintainer needs more info) » Active

This is the only standing issue we have at Slick as of this writing.

We need to put it into the latest development 2.x branch first, and then back port it as needed.

I don't have to worry much about themers, since these buttons are printed in Twig, I think they can always update it as needed.
Most end users, especially if the Optimized option is enabled, will not be affected since the arrows HTML and most settings are never stored in the first place, anyway.

gausarts’s picture

Status: Active » Needs review
StatusFileSize
new5.88 KB

Attached is to remove the HTML tags from the arrow options and leave it as texts.

  • gausarts committed 38d39bb on 8.x-2.x
    Issue #3075838 by volkerk, gausarts: Configuration translation...
gausarts’s picture

Version: 8.x-2.x-dev » 8.x-1.x-dev

Let's get the ball rolling one at a time.

gausarts’s picture

StatusFileSize
new6.81 KB

Let's see if any issue.

  • gausarts committed 61db18b on 8.x-1.x
    Issue #3075838 by volkerk, gausarts: Configuration translation...
gausarts’s picture

Version: 8.x-1.x-dev » 7.x-3.x-dev

Also fixed few CS leftovers. We'll drill down.

gausarts’s picture

StatusFileSize
new7.48 KB

Let's see if any issue.

gausarts’s picture

Version: 7.x-3.x-dev » 7.x-2.x-dev

One more.

gausarts’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev

Too fast.

  • gausarts committed 5b0a15e on 7.x-3.x
    Issue #3075838 by volkerk, gausarts: Configuration translation...
gausarts’s picture

Version: 7.x-3.x-dev » 7.x-2.x-dev
gausarts’s picture

StatusFileSize
new14.1 KB

Hopefully last 2 as it appears 8.x-1.x-dev failed with tests actually. Wrong green at #9.

  • gausarts committed ec63947 on 7.x-2.x
    Issue #3075838 by volkerk, gausarts: Configuration translation...
gausarts’s picture

Version: 7.x-2.x-dev » 8.x-1.x-dev
gausarts’s picture

StatusFileSize
new604 bytes

Fixed for leftover.

  • gausarts committed 7de9b59 on 8.x-1.x
    Issue #3075838 by volkerk, gausarts: Configuration translation...
gausarts’s picture

Status: Needs review » Fixed

I will follow up tomorrow if anything I missed or you find any issue.
Let's close this for now. Thank you for contribution!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

joachim namyslo’s picture

This is still valid. Here are two examples from de

https://localize.drupal.org/translate/languages/de/translate?sid=2514073
https://localize.drupal.org/translate/languages/de/translate?sid=2514075

Varbase uses the latest 8.2.x branch and if we translate this the mallformed html filter detects theese strings as invalid although of this patch. So the bug still presists.

See updated dblog screenshot in referenced issue.

gausarts’s picture

Thank you.

You are right about this particular branch.

I haven't released a new one since then:

8.x-1.2: 1 January 2020
The patch: 14 Jan 2020

If you meant something else such as the patch doesn't work, please let me know.

joachim namyslo’s picture

joachim namyslo’s picture

I simply meant if the patches are committed to the dev-branch and downwards. The strings here are still untranslatable. In other words: If we translate them they still got skipped. So we can defacto not translate them. Maybe because the patch is not committed to all affected module versions right now.

This is not the only module struggling with this. So either we inform each module maintainer manually. Or a documentation change on API docs is necessary to inform all maintainers at once.

See: #3157707: Prevent strings unsafe for translation in code