Describe your bug or feature request.
Product attribute value labels displayed in the Add to Cart form dropdown are not translated.
For example, on a French language domain, the attribute select options still display in English.
The issue is in
ProductVariationAttributeMapper::getAttributeValues().
The method calls
$variation->getAttributeValue($field_name), which internally uses
CommerceContentEntityBase::ensureTranslations() to resolve the translation.
However, ensureTranslations() determines the target language based on the parent
variation entity's own language
($this->language()->getId() when translatable, or
getCurrentLanguage(TYPE_CONTENT) when not).
This is unreliable in several scenarios:
- When the variation entity is translatable but was loaded in the original language
- During AJAX requests where content language negotiation may not resolve correctly
- On sites using domain-based language negotiation
Meanwhile, in the same class, the attribute entity itself is correctly translated on line 89
using EntityRepository::getTranslationFromContext(), but the attribute values do not receive the same treatment.
If a bug, provide steps to reproduce it from a clean install.
- Use domain translation on current site
- Add translation to the attributes
- Add field formatter 'Add to cart'
- Check the transltions
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | commerce_attribute_value_translation-3585248-2.patch | 760 bytes | foxy-vikvik |
Issue fork commerce-3585248
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
foxy-vikvik commentedComment #3
ivnishComment #5
ivnish