Skip to content

Unable to translate custom attributes in admin backend #13250

Closed
@cmuench

Description

@cmuench

Preconditions

A custom attribute is created.
We have different frontend labels for the attribute. Store views with different locale settings exist.
Admin users are speaking different languages and need a localized attribute label.

Steps to reproduce

Create an custom attribute with different frontend labels.

Expected result

There are two possible results:

  1. A user can see the specific frontend label of the selected store-view. This could be a problem e.g. the user speaks french and the assigned locale of the store view is in another language.

  2. The default frontend label can be translated e.g. with the Magento translation functions. This needs a i18n language file or that we can use the inline translation in admin backend.

Actual result

The default frontend label is used.
Have a look into this method:
\Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::setupAttributeMeta.

$meta = $this->arrayManager->set($configPath, [], [
            'dataType' => $attribute->getFrontendInput(),
            'formElement' => $this->getFormElementsMapValue($attribute->getFrontendInput()),
            'visible' => $attribute->getIsVisible(),
            'required' => $attribute->getIsRequired(),
            'notice' => $attribute->getNote(),
            'default' => (!$this->isProductExists()) ? $attribute->getDefaultValue() : null,
            'label' => $attribute->getDefaultFrontendLabel(),  // <-- This is the line
            'code' => $attribute->getAttributeCode(),
            'source' => $groupCode,
            'scopeLabel' => $this->getScopeLabel($attribute),
            'globalScope' => $this->isScopeGlobal($attribute),
            'sortOrder' => $sortOrder * self::SORT_ORDER_MULTIPLIER,
        ]);

At least the translation function should be used:

'label' => __($attribute->getDefaultFrontendLabel()),

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions