Hi;

Just a quick patch for a missing t('') wrapper for the string "Please select" that appears before the product variations select tag.

Without the wrapper, this string appears as untranslatable for site builders and end-users.

Comments

idiaz.roncero created an issue. See original summary.

idiaz.roncero’s picture

bojanz’s picture

Title: Missing translation wrapper for 'Please select" string » The ProductVariationTitleWidget label_text cannot be translated
Version: 8.x-2.7 » 8.x-2.x-dev
Assigned: idiaz.roncero » Unassigned

Retitling for clarity.

Unfortunately, this fix won't work. Config is saved in the default site language, and using t() here will use the user's current language.
So if I have a site with French as the default language and Serbian as the second language, and I edit the page in Serbian, the Serbian version of the label will be saved to config, even though the langcode will be "fr". And then on the site, both "fr" and "sr" pages will show the Serbian text.

Our main problem is that Drupal core doesn't support translating widget settings yet.

megadesk3000’s picture

StatusFileSize
new768 bytes
new843 bytes

Hey

I made the patch a little different. So putting the configured string into t function during rendering the widget. Like that, the text can be translated afterwards.
I know its not the cleanest solution, since t() should only contain string litereals, but i think thats acceptable until there is a better solution.

What do you think?

megadesk3000’s picture

Status: Active » Needs review

bojanz’s picture

Status: Needs review » Fixed

I agree, let's proceed with #4 as a workaround. Added a code comment as an explanation.

  • bojanz committed f75e72f on 8.x-2.x
    Issue #2980695 followup: Tell phpcs to stop complaining about variables...

Status: Fixed » Closed (fixed)

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