I have a website and for a product like "shirts" there is a way to get a discount. (This is implemented by a custom option). I'm importing all the products and the options programmatically. But now in the other languages it has to be changed. Because it is the same sentence it would be nice if it could be translated whitin a .csv file. But how do I change te code? In the picture the custom option "Discount brest logo". But In German I want there the text "Rabatt.."

enter image description here

I saw in the browser there is a reference to class="label admin__field-label.

enter image description here

I found out that in "magento/module-catalog/Block/Product/View/Options/Type/Select.php" this piece of code is creating the text of the custom option:

$this->pricingHelper->currencyByStore($_value->getPrice(true), $store, false) .
                '" />' .
                '<label class="label admin__field-label" for="options_' .
                $_option->getId() .
                '_' .
                $count .
                '"><span>' .
                $_value->getTitle() .
                '</span> ' .
                $priceStr .

So two questions:

  1. Is this the right place for translate ""Discount brest logo"??
  2. But how do I translate "$_value->getTitle() ." correctly so I can use te .csv file?

1 Answer 1


This is the Magento-way solution:

The translation of those labels is a core functionality.

Just navigate to product edit form and edit Customizable options tab with correct Store View selected in upper-left corner store switcher. Then save your changes.

If in your case you have a lot of options, you should be able to do this by some db updates using Data Patch for example.

The faster and dirtier way to achieve that is to use global translation functionality:

The core template for custom option checkboxes is here:


In the line 81 you can see:

        <label class="label admin__field-label"
               for="options_<?= $block->escapeHtmlAttr($option->getId() . '_' . $count) ?>">
                <?= $block->escapeHtml($value->getTitle()) ?>
            <?= /* @noEscape */ $block->formatPrice($value) ?>

You can copy whole template to your custom theme and change that line to something like this:

<?= $block->escapeHtml(__($value->getTitle())) ?>

That will translate whatever you have as title inside your custom option configuration.

All your translations should be added in corresponding CSV file (de_DE.csv) inside i18n directory.

  • Dear Duzdio. I think changing 10.000 articles by hand is not an option :) That's why I asked a "translation solution :) " Commented May 18, 2021 at 9:22
  • I've updated answer to your expectations ;)
    – dudzio
    Commented May 18, 2021 at 9:40
  • 1
    Dudzio,thanks for putting me on the right track!!! In the PHP coding I just changed "$_value->getTitle() " into "__($_value->getTitle())" and this works like a charm!! Sometime things can be simple!!!!! Commented May 18, 2021 at 12:40
  • I'm really happy! If you find your file somewhere else, please let me know and I will update the answer, thanks :)
    – dudzio
    Commented May 18, 2021 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.