I'm aware of issue #2725453: Refactor widget plugins by adding interface, base class, schema, but I thought others could benefit from this patch. It just puts the output of the default option label through the t-function when building the dropdown widget.

To be clear; this does not apply when rendering the configuration form, this will always hold the original string.

Do you need a test? Personally, I think this is out of scope because the StringTranslationTrait has already been tested.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

LammensJ created an issue. See original summary.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

I don't think we need to test this, this looks good. Thanks!

borisson_’s picture

Status: Reviewed & tested by the community » Fixed

Thanks!

  • borisson_ committed 7b17590 on 8.x-1.x authored by LammensJ
    Issue #2752819 by LammensJ: Translate the default option label
    

Status: Fixed » Closed (fixed)

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

matteodem’s picture

The text is not translatable in the latest version. Here's the patch to fix it.

pfrenssen’s picture

@matteodem the original fix was not correct and it has been removed again. Dynamic strings should never be passed through $this->t().

The label can be translated in the standard way by enabling the Config Translation module.