Discussions

How do I translate the options in attribute field select lists?

Hi,
I've developed a Commerce Site using Drupal Commerce. The project is started one year ago.
The Products Types was created using "Term Reference" Field connected to a "Localized" taxonomy vocabulary.
The user create the Products and later translate it using "Entity Translation". When all variants are created and translate this products are connectde to a "View Node" using a "Product Reference" Field.
The view node use Multilingual Support of Internationalization to translate it (there is not enable Entity Translation).
When I've started to develope the project this system was working correctly and translation was showed correctly also inside the "selction form" of product variants. This till the version RC1 of entity API.

When the version of EntityAPI has been update to version RC2 (I've tested it also with the latest dev version) the "Selction Form" of variant product don't translate more the vocabulary terms. I've checked the products and they are translated.
If I configure the "product reference" field to "Render fields from the referenced products when viewing this entity." I see the option into the node correctly translated.

I've create a new clear installation of drupal with "Drupal Commerce" - "Internationalization" - "Entity Translation" - "Entity API" to replace the problem (see the attached image). I've make a lot of test to understand if there was some wrong configuration. Every time I have the same result. If I put on the server EntityAPI - RC1 i see the "selection field" translated, if I put a new version of EntityAPI from RC2 to latest DEV the the "selection field" are not translated.

I've looking for into the drupal site and commerce guy site to find if there was some other issue with the same problem but without result.

Someone have the same problem and he can help me to solve it?

Ps. This discussion is migrated here from a starting isuue on Drupal.org - http://drupal.org/node/1982670 - where rszrama propone this trick inside the i18n_field module:

<?php
// Prepare translated options if using the i18n_field module.
if (module_exists('i18n_field')) {
  if ((
$translate = i18n_field_type_info($field['type'], 'translate_options'))) {
   
$allowed_values = $translate($field);
   
_options_prepare_options($allowed_values, $properties);
  }

 
// Translate the field title if set.
 
if (!empty($instance['label'])) {
   
$instance['label'] = i18n_field_translate_property($instance, 'label');
  }
}
?>
AttachmentSize
Image icon entityapi.jpg81.58 KB
Posted: Apr 29, 2013

Comments

andrea.brogi on August 21, 2013

I'm not a programmer so my operability is limited.
I've a test web site where I have a clean istallation of Drupal 7 with Commerce - i18n - entity - entity translation - inline_entity_form
configured as decribed in this post.

This my translated node as example: http://www.m2r2-comunicazione.it/en/test-product

Directly on this site I've added into i18n_field.module the code proposed but nothon is changed.
Some other suggestion?

bojanz Bojan Zivanovic on August 21, 2013

There should be no issues today with i18n 1.9 (the 1.8 release was completely broken) and Commerce 1.8.

I have personally tested the translation use cases and have confirmed that the following use cases work:
1) Product with attributes coming from an options field, where the options are translated using i18n_field.
2) Product with attributes coming from a vocabulary, using Entityreference and the Title module.
3) Product with attributes coming from a vocabulary, using Taxonomy term reference, the Title module, and the patch from https://drupal.org/node/2013985

The last two use cases assume Entity Translation is used together with Title for translating the taxonomy terms (which makes sense since the same module is used for Products as well. It makes sense to use it for all entity types, including nodes, for consistency).
Also, Inline Entity Form doesn't play nice with translations at the moment.

andrea.brogi on August 27, 2013

Hi bojanz,
I'm tring to reproduce the step 3.
I've installed "title" and applyed the patch. I have created a product with attributes coming from vocabulary using Taxonomy Term reference and a I have created a Product Display Node using Product Refrence. I'm using Entity Tranlastion for product, taxonomy and node.
I have two vocabulary like product option.
Into Italian Language (Main) i see the two Select list option instead when I switch to English version I see only one form showing the translated title instead of Option Form...

http://www.m2r2-comunicazione.it/en/test-0