There is currently no good way to translate the "Allowed values" that we use in select controls. This means that 1) In the product fields there's no way to present allowed values

The D7 CCK module provides a UI where allowed values can be provided by PHP code, but it's 1) ugly, 2) fragile, 3) relies on the PHP filter. But it does seem to work - you provide the allowed values in a php snippet which puts t() around the allowed values.

There is consideration/discussion of adding some capability to control this in #1030066: Translation of option labels (allowed values).

Procedure for translating a product using CCK:

  • Follow the basic steps outlined in http://randyfay.com/node/88 to set up the site (and enable the contrib translation module). I set up URL-driven translation with en.commerce.l, es.commmerce.l, and de.commerce.l. Note that you need a patched title module.
  • Use and enable CCK head
  • In the product display node type (the one that references products) go to settings, and under Publishing Options vertical tab, choose "Multilingual support, with content translation".
  • Create a product type at admin/commerce/products/types/add. I'll make a "hat" type.
  • Add a field for Size of field type List(text) and widget "Select list"
  • In the field settings, use the Allowed Values PHP Code return array('small' => t('Small'), 'medium' => t('Medium'), 'large' => t('Large'));. Note that this is quite finicky. If somebody makes a mistake in the PHP code it's an unrecoverable fatal (I think) without going into the db.
  • To translate the product display title. admin/structure/types/manage/product-display/fields and click "replace" on title to make it a field.
  • Create a product (in my case, a hat product). admin/commerce/products/add/hat. I'll create HAT-SMALL.
  • Visit the HAT-SMALL page in a language that requires translation. I'll use Spanish and visit es.commerce.l/admin/commerce/products/8/edit. This adds "Small" to the interface translations so we can find it and translate it.
  • At admin/config/regional/translate/translate, enter translations of "Small", "Medium", and "Large" for Spanish and German.
  • Translate field labels as necessary. For example, "Product".
  • Create medium and large hat products at admin/commerce/products/add/hat
  • Create a product reference node (Mine is at node/add/product-display) configured to sell the 3 sizes of hats we've built. Set the language to English.
  • Use the "Translate" tab to translate the node to Spanish and German. Make sure in the collapsed-by-default "Translation settings" that you set "this translation is published". Use different titles and bodies for each language. See #1031370: Translation publishing status is hidden under collapsed "publishing options" fieldset (and is hidden by default).
  • Visit the node in English, Spanish, and German to see the results. In my case, http://en.commerce.l/node/7, http://es.commerce.l/node/7, and http://de.commerce.l/node/7.

Remaining issues:
  • Product entity titles are not translatable yet. The title module intends to do this. This means that the description in a product selection field in a product display node is always in the source language (until entity titles are translatable).
  • The hacky approach to allowed values is almost certainly not sustainable. Looks like something from 4.6.

Comments

pcambra’s picture

Great summary, thanks Randy.

pcambra’s picture

Does the new Entity translation module fit anywhere on this step by step? http://drupal.org/project/entity_translation

das-peter’s picture

Thanks Randy for this summary. Just got the message from druplicon to check this out :)
I hope I can continue work on the remaining issues asap.
There was a huge progress on the title module - but I didn't have the chance to check it out. I hope the progress there covers remaining issue 1.

pcambra’s picture

giorgosk’s picture

http://drupal.org/project/title does indeed work great with products
and seems that this issue should be marked fixed !!

das-peter’s picture

The title module made indeed some very nice progress - unfortunately there are still some issues that introduce some special knowledge about how to handle products on multilingual pages.
E.g.:

#1157446: Integrate the module entitycache to enhance the support for title translation
You need to know that you should use the title_field instead the title property to make sure there's no caching issue.
#1269076: Translated title_field replaces node->title with translated value
This could break stuff that relies on the title property.
bojanz’s picture

Status: Active » Closed (duplicate)

There is nothing more to be done here.

If you're using a List(text) field for an attribute, you can translate the allowed values using i18n_field 1.8 + the patch at #1904368: [7.x-1.8 regression] Field translation fails in numerous situations.
If you're using entityreference or taxonomy_term_reference fields for the attributes, then you need to use entity_translation + title to translate the terms.
For the terms to be translated in the dropdown you need to:
- For entityreference, use the -dev release, or a stable release newer than June 6th 2013, since this required patch got committed: #2013849: Term names are not translated.
- For taxonomy_term_reference, you need this Title patch: #2013985: Title replacement doesn't happen for taxonomy term references

I am working with other people from Commerce Guys to document all dependencies and needed steps to fully translate a Drupal Commerce site.