Configure entity translation for Drupal Commerce

Last updated on
4 May 2017

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

This documentation page is based on an extensive comment by j2b. Needs rewording and style review. Will need updating once the commerce patch in #1495570: Update Entity translation integration is committed.

Basis

At the time of writing the Drupal Commerce Kickstart distribution (dev 2.x) does not work properly with Entity Translation. This document was created with the help of a clean copy of Commerce and the following modules: Search API, Facet API, Views, Entity, Commerce, Entity Translation, i18n. The Entity Cache was not installed. (@todo why?)

Choosing multi-language workflow

The main difference between going the pure Internationalization (i18n) way and the Entity Translation (ET) way is in fact, how nodes are considered by Drupal. In short - if we go pure i18n way, each language node is a separate node. If we go with ET - there is only one node for all languages. There are pros and cons, regarding choice of language handling. If you use something like the Fivestar widget to rate products, then the i18n way will mean that you get separate ratings for the same product in each translated language.

Mainly my choice was connected to the fact, that I have chosen Search API and Facet API to provide product sorting screens, which actually do not work well with the ET solution, as all nodes are considered to be original language, so not letting me filter out display nodes by current user language. Mainly in facets and display nodes handling. But still ET does the job here, presenting translated fields, but not facets - taxonomy terms in proper language.

So, what's working?

Latest devs up till today of:

  • Entity (7.x-1.x-dev 2012-Sep-07),
  • Entity Translation (7.x-1.x-dev 2012-Oct-15) and
  • Commerce (7.x-1.x-dev 2012-Oct-13).

To overcome Language selection issues and probably Access denied issues (mentioned in this thread above) regarding Translation tab availability, I applied plach's recommended patch (#1495570-15: Update Entity translation integration).

Now I am able to create new products in /admin/commerce/products section, and am presented with Translate link besides each product, where I can choose language and translate field (Title) configured for this.

After all, I create a bunch of product variations, translate these, and further move to display node creation (i18n style) - separate node per language. I fill up fields in product's display node, assign taxonomy terms (translation provided via i18n bundle module) and add existing product variations. Initially I do this in English, which is site's default language.

After I am presented with Translate tab, where I choose to add Translation to another language (creating new display node). Translating all fields but product reference fields, which are automatically populated, still in original language, but I leave it so.

After I save display node in other language, ET is replacing English Title string with particular language string, and display nodes are separated by languages in Search API type view. Including correct language taxonomy term representation in particular language view.

My settings

Regarding Entity Translation introductions:

  • Enable language fallback
  • Display shared labels
  • Select which entities can be translated: Node; Commerce product
  • Details for Commerce product: Selected Author's language and no checkboxes at all

Languages selection/detection (admin/config/regional/language/configure):

  • Selected/added all necessary languages, still leaving English as default, manually added en prefix for English default, to make clear separation, as I am using prefix for language separation.
  • User interface text language detection: URL; Default
  • Content language detection: Interface (moved to top manually); URL; Default

Commerce product type settings (admin/commerce/products/types/product/edit):

  • Enabled via Entity Translation

admin/commerce/products/types/product/fields

  • Replaced regular Drupal Title field with Title module, and in this field settings checked, that this is the only field in Product type I'm going to allow translation.

Product display node content type settings from admin/structure/types/manage/{your-display-type}

  • Published options > Multilingual support - selected: Enabled, with translation (NOT Enabled, with field translation, as I'm going to use i18n for language and node separation).
  • My title field in this display node, which is overridden by Title module is left for field translation, as these are per field settings, not per content type.
  • There are no any other fields let for entity translation in product display node, even product reference field (used with inline entity form).

Basically that's all. Taxonomy term translation is handled by i18n modules and Taxonomy vocabulary has Translate... (NOT Localize...) settings - different name for each language tied into translation sets.

Search API is using search_api_db sub-module for search handling.

Help improve this page

Page status: No known problems

You can: