Problem/Motivation

Entity Translation does not play well with the i18n_taxonomy module of the Internationalization suite. There are lots of conflicts both at UI and API level, because both modules try to handle the translation process, with hugely different approaches.

Proposed resolution

  • Define a 5th option in the vocabulary translation settings, explicitly enabling ET for that particular bundle. This way ET will not touch terms that are meant to be translated via i18n.
  • Even when i18n_taxonomy is not enabled allow to enable ET per vocabulary similarly to what we do for content types.

Remaining tasks

None

User interface changes

API changes

None

Data model changes

None

Comments

plach’s picture

Title: ET UI alters shouldn't happen if node type isn't using ET » I18n Taxonomy integration
Category: bug » task
FileSize
662 bytes
PASSED: [[SimpleTest]]: [MySQL] 62 pass(es). View

We need a far better integration with i18n_taxonomy, which right now is really confusing and not really working well. Attached there is a first stab at ensuring that at least the i18n_taxonomy and ET translation for taxonomy can work together.

We need an option in the vocabulary settings specifying that ET translation is enabled for that particular vocabulary.

plach’s picture

Status: Active » Needs review
plach’s picture

Status: Needs review » Active

Committed and pushed #1. Back to active.

bforchhammer’s picture

plach’s picture

I think we should simply define a 5th option in the vocabulary translation settings, explictly enabling ET for that particular bundle (we need to add a bundle callback for taxonomy).

mvdve’s picture

I agree. It would be amazing to have the same functionality as the node entity translations.
This would make the functionality generic and much easy-er to understand.
So an fifth option in the translation settings of the taxonomy vocabulary should be the best option.

This makes the import (with feeds) of multilingual taxonomy terms possible. You have to make a lot of custom functionality to make this happen now.

If I can help in any way, let me know.

  • Commit 82e3871 on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions by plach:
    Issue #1661348 by plach | liquidcms: Fixed minimal i18n Taxonomy...

  • Commit 82e3871 on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions, workbench by plach:
    Issue #1661348 by plach | liquidcms: Fixed minimal i18n Taxonomy...
plach’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
9.85 KB
FAILED: [[SimpleTest]]: [MySQL] 721 pass(es), 0 fail(s), and 203 exception(s). View

This seems to be working correctly.

plach’s picture

We should probably add an update function.

plach’s picture

FileSize
149.8 KB

Here is a screenshot:

Status: Needs review » Needs work

The last submitted patch, 9: et-i18n_taxonomy-1661348-9.patch, failed testing.

plach’s picture

Status: Needs work » Needs review
FileSize
10.02 KB
PASSED: [[SimpleTest]]: [MySQL] 721 pass(es). View
1.64 KB

Slightly better patch.

plach’s picture

Priority: Normal » Major
blacksnipe’s picture

I've tried both patches in #9 and #13. Here's my feedback:

When I leave the checkbox (not like the screenshot?) unchecked, it doesn't do a thing - works as expected.
But if I check it for a taxonomy, it gets my records in the entity_translation-table deleted whenever I try to save an edit!

plach’s picture

Are you sure you are not experiencing #2396103: [DATA LOSS] Translations deleted?

gonssal’s picture

So, I got to that point where you have a perfectly working translated taxonomy tree in a vocabulary, and then you have to edit the vocabulary, so all your default language terms are reset to 'und' language. It's so much enjoyable and fun. This breaks the entity translation, if I'm not mistaken, due to this in the entity_translation table:

entity_type | entity_id | language | source
taxonomy_term | 1 | ca | en
taxonomy_term | 1 | es | en
taxonomy_term | 1 | und |  

Also the 'language' column in the 'taxonomy_term_data' is set to 'und'.

This effectively breaks all the translations because their source language is no longer present. Apart from that, the Translate tab doesn't appear on the terms edit page (I guess it's because the term language is also set to 'und'), so you can't delete the translations. Even if you try to delete them by using "taxonomy/term/[tid]/translate/delete/[langcode]", it won't work. So basically everything breaks. The only what to get it "fixed" is executing UPDATE `taxonomy_term_data` SET `language` = 'en', where 'en' will be your site's default language. Even if you uncheck the "Hide language selector" and the "Exclude Language neutral from the available languages" options in the ET settings for the taxonomy term, it won't let you change the 'und' language because it gets one of the "orphan" translations instead of the 'und' entry.

I applied the patch on beta3 and got the following error:

Hunk #5 FAILED at 881.
1 out of 5 hunks FAILED -- saving rejects to file entity_translation.module.rej

I checked anyways and the new "Field translation. Term fields will be translated through the Entity translation module." option appeared, was selectable and it sucessfully saved the new setting. Sadly, nothing changed and my taxonomies were still "stuck".

I then updated to -dev, ran update.php and reapplied the patch. The new "Field translation..." option is not there now.

If I'm not mistaken, I think all of this mess would be resolved by fixing the #2366585: Saving a vocabulary resets all terms to LANGUAGE_NONE issue, and not the other way arround as you commented in there. I might be wrong though.

plach’s picture

Well, the idea is that this patch (that should be applied to the latest -dev) would prevent you from configuring your site in a way that triggers #2366585: Saving a vocabulary resets all terms to LANGUAGE_NONE. It can do nothing to recover data, sorry.

gonssal’s picture

So what happens when a user switches from Drupal's content translation to entity translation? I mean, there's even a migration submodule in ET that provides an "upgrade path".

Also, as I noted, even after applying the patch to the -dev version, the "Field translation. Term fields will be translated through the Entity translation module." option isn't appearing for me.

Don't get me wrong, I'm fine with looking at code, applying patches and running SQL queries, but I'm sure there's people getting crazy trying to understand what's happening with their taxonomy right now.

Nchase’s picture

applied the patch from #16 gave me two problems:

1. all Tag titles / descriptions were empty (using title module)
2. Views doesn't recognize the language selection (relationship + entity translation filter)

Nchase’s picture

views does recognize the language selection but when I configure a taxonomy view to display the taxonomy term names of a vocab I get the terms in the original language but the links to the translated language.

$view = new view();
$view->name = 'tagclouds';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'taxonomy_term_data';
$view->human_name = 'Tagclouds';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['group_by'] = TRUE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['row_options']['inline'] = array(
  'name' => 'name',
  'name_1' => 'name_1',
);
/* Relationship: Taxonomy term: Content with term */
$handler->display->display_options['relationships']['nid']['id'] = 'nid';
$handler->display->display_options['relationships']['nid']['table'] = 'taxonomy_index';
$handler->display->display_options['relationships']['nid']['field'] = 'nid';
$handler->display->display_options['relationships']['nid']['label'] = 'Beitrag';
/* Relationship: Taxonomy term: Entity translation: translations */
$handler->display->display_options['relationships']['entity_translations']['id'] = 'entity_translations';
$handler->display->display_options['relationships']['entity_translations']['table'] = 'taxonomy_term_data';
$handler->display->display_options['relationships']['entity_translations']['field'] = 'entity_translations';
/* Field: COUNT(Taxonomy term: Name) */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['group_type'] = 'count';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['exclude'] = TRUE;
$handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
/* Field: Taxonomy term: Name */
$handler->display->display_options['fields']['name_1']['id'] = 'name_1';
$handler->display->display_options['fields']['name_1']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['name_1']['field'] = 'name';
$handler->display->display_options['fields']['name_1']['label'] = '';
$handler->display->display_options['fields']['name_1']['alter']['text'] = '[name_field_et]';
$handler->display->display_options['fields']['name_1']['element_class'] = 'tags tag-[name] tag-dist-[counter]';
$handler->display->display_options['fields']['name_1']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name_1']['link_to_taxonomy'] = TRUE;
/* Sort criterion: Global: Random */
$handler->display->display_options['sorts']['random']['id'] = 'random';
$handler->display->display_options['sorts']['random']['table'] = 'views';
$handler->display->display_options['sorts']['random']['field'] = 'random';
/* Filter criterion: Taxonomy term: Vocabulary */
$handler->display->display_options['filters']['vid']['id'] = 'vid';
$handler->display->display_options['filters']['vid']['table'] = 'taxonomy_term_data';
$handler->display->display_options['filters']['vid']['field'] = 'vid';
$handler->display->display_options['filters']['vid']['value'] = array(
  7 => '7',
);
/* Filter criterion: COUNT(Taxonomy term: Name) */
$handler->display->display_options['filters']['name']['id'] = 'name';
$handler->display->display_options['filters']['name']['table'] = 'taxonomy_term_data';
$handler->display->display_options['filters']['name']['field'] = 'name';
$handler->display->display_options['filters']['name']['group_type'] = 'count';
$handler->display->display_options['filters']['name']['operator'] = '>';
$handler->display->display_options['filters']['name']['value']['value'] = '0';
/* Filter criterion: Entity translation: Language */
$handler->display->display_options['filters']['language']['id'] = 'language';
$handler->display->display_options['filters']['language']['table'] = 'entity_translation';
$handler->display->display_options['filters']['language']['field'] = 'language';
$handler->display->display_options['filters']['language']['relationship'] = 'entity_translations';
$handler->display->display_options['filters']['language']['value'] = array(
  '***CURRENT_LANGUAGE***' => '***CURRENT_LANGUAGE***',
);

/* Display: Panel: Web tags */
$handler = $view->new_display('panel_pane', 'Panel: Web tags', 'panel_pane_1');

/* Display: Panel: Web tags en */
$handler = $view->new_display('panel_pane', 'Panel: Web tags en', 'panel_pane_2');
$handler->display->display_options['defaults']['relationships'] = FALSE;
/* Relationship: Taxonomy term: Content with term */
$handler->display->display_options['relationships']['nid']['id'] = 'nid';
$handler->display->display_options['relationships']['nid']['table'] = 'taxonomy_index';
$handler->display->display_options['relationships']['nid']['field'] = 'nid';
/* Relationship: Taxonomy term: Entity translation: translations */
$handler->display->display_options['relationships']['entity_translations']['id'] = 'entity_translations';
$handler->display->display_options['relationships']['entity_translations']['table'] = 'taxonomy_term_data';
$handler->display->display_options['relationships']['entity_translations']['field'] = 'entity_translations';
$handler->display->display_options['relationships']['entity_translations']['required'] = TRUE;
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: COUNT(Taxonomy term: Name) */
$handler->display->display_options['fields']['name']['id'] = 'name';
$handler->display->display_options['fields']['name']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['name']['field'] = 'name';
$handler->display->display_options['fields']['name']['group_type'] = 'count';
$handler->display->display_options['fields']['name']['label'] = '';
$handler->display->display_options['fields']['name']['exclude'] = TRUE;
$handler->display->display_options['fields']['name']['element_label_colon'] = FALSE;
/* Field: Taxonomy term: Name */
$handler->display->display_options['fields']['name_field']['id'] = 'name_field';
$handler->display->display_options['fields']['name_field']['table'] = 'field_data_name_field';
$handler->display->display_options['fields']['name_field']['field'] = 'name_field';
$handler->display->display_options['fields']['name_field']['label'] = '';
$handler->display->display_options['fields']['name_field']['exclude'] = TRUE;
$handler->display->display_options['fields']['name_field']['element_class'] = 'tags tag-[name] tag-dist-[counter]';
$handler->display->display_options['fields']['name_field']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name_field']['settings'] = array(
  'title_style' => '_none',
  'title_link' => '',
  'title_class' => '',
);
$handler->display->display_options['fields']['name_field']['link_to_entity'] = 1;
/* Field: Taxonomy term: Name */
$handler->display->display_options['fields']['name_1']['id'] = 'name_1';
$handler->display->display_options['fields']['name_1']['table'] = 'taxonomy_term_data';
$handler->display->display_options['fields']['name_1']['field'] = 'name';
$handler->display->display_options['fields']['name_1']['label'] = '';
$handler->display->display_options['fields']['name_1']['element_class'] = 'tags tag-[name] tag-dist-[counter]';
$handler->display->display_options['fields']['name_1']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['name_1']['link_to_taxonomy'] = TRUE;
$translatables['tagclouds'] = array(
  t('Master'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('Beitrag'),
  t('Translations'),
  t('[name_field_et]'),
  t('Panel: Web tags'),
  t('View panes'),
  t('Panel: Web tags en'),
  t('node'),
);

I don't know if this is a entity translation or a views problem.

colan’s picture

Status: Needs review » Needs work

I tried turning i18n_taxonomy on, off, uninstalling it. No matter what I do, I always hit the following:

Fatal error: Cannot redeclare EntityTranslationTaxonomyTermHandler::getLanguage() in /path/to/drupal/sites/all/modules/contrib/entity_translation/includes/translation.handler.taxonomy_term.inc on line 55

Maybe it needs to be re-rolled?

colan’s picture

Yup, this method was already defined in #2203801: Impossible to update taxonomy term after enabling i18n_taxonomy which was committed a month after #13 was written.

plach’s picture

badrange’s picture

Issue summary: View changes
FileSize
6.1 KB

Attached is an updated patch that is created from 7.x-1.x that takes colan's comment into account. I hope it makes sense. What I did was remove the getLanguage() function call from the patch, and add the new I18N_MODE_ENTITY_TRANSLATION to the translation mode check that should trigger entity translation for the term entities.

Note: without the new
if ($mode == I18N_MODE_NONE || $mode == I18N_MODE_ENTITY_TRANSLATION ) {
the data in the terms name_field and description_fields was deleted.

badrange’s picture

FileSize
10.15 KB
1.33 KB

Attaching interdiff and a new version of the patch, seems like I messed up when creating it.

badrange’s picture

Status: Needs work » Needs review
badrange’s picture

Oh how could I upload a patch with .txt ending AND no newline at the end of the file. Such unprofessional.

candelas’s picture

Hello

Since this issue is a blocker for Entity Translation 1.0 https://www.drupal.org/node/1624830 and now plach is working on this, please, test. Also, Entity Translation is asking for a coo-maintainer. I wish I had the knowledge to apply since it is a great opportunity to learn from a senior developer...

I have test in a new demo Commerce Kickstart 7.x-2.37 installation. When I installed, I selected that it will be translatable. Steps I made:

  • Apply patch #28
  • Enable Title and Entity Translations modules (There is not the internationalization module installed). The locale module was enabled because of being required.
  • Import Catalan language
  • Edit taxonomy Collection and make it translatable
  • Change name field to be translatable
  • In Entity Translation settings, I have only the 'Hide language selector' configured and the rest as default.
  • Edit one term and select the translation tab
  • Create the Catalan translation
  • The translation works.

I have tried also in a customized Commerce Kickstart and it works. I have this modules enabled (they are related for translation): hreflang, languageicons, i18n_block, i18n_contact, i18n_field, i18n, i18n_menu, i18n_path, rules_i18n, i18n_string, i18n_redirect, i18n_translation, i18n_user, i18n_variable and i18nviews. So no incompatibilities with them.

Have a good weekend!

EDIT: I forgot to say that in the customized CK, I had to re-make the taxonomy translatable in its edit form. Also in the customized one, I tested the different options that are in the Entity Translation form, as "Exclude Language neutral from the available languages", and they work without problems.

plach’s picture

I tested #28 plus some small additions you can see in the interdiff and it seems to be working well and allowing to configure different vocabularies with different translation modes (ET, i18n, none).

The patch also provides an upgrade path, since now translation needs to be explicitly enabled for each vocabulary requiring entity translation. Be sure to backup your site before testing this.

I'd like to commit this on -dev ASAP, unless there are major flaws with it, so we can start widening the testing user base.

  • plach committed 7a45648 on 7.x-1.x
    Issue #1661348 by plach, badrange, colan, candelas: Added "I18n Taxonomy...
plach’s picture

Status: Needs review » Fixed

Ok, committed and pushed.

Thank you all for your help! If you find problems please file new issues and reference them from here.

plach’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Triumphent’s picture

Last patch works well for me. Thanks. :)

adam1’s picture

Despite I installed the newest dev version of the module (where the patch is included already - isn't it?), on some terms I got no translate tab and got the message "access denied" when I tried to edit or delete them. In the vocabulary settings the 'fieldtranslation' setting is enabled.
What's the trick?

webmasternew’s picture

7.x-1.x-dev
Notice: Undefined index: href in menu_local_tasks() (line 2070 of /var/www/reg_ru/data/www/taxi.lazy.su/includes/menu.inc).