Problem/Motivation

The i18n_taxonomy module is broken when using translate terms.

The page taxonomy/term/[tid]/translate let the user type a term name in each autocomplete field, allowing to find the corresponding term in the target language.

If the vocabulary contains terms which have the same exact spelling (in the same language), then you won't ever be sure that the translation link created is the right one.

Why this happens?

i18n_taxonomy.admin.inc, i18n_taxonomy_autocomplete_validate uses:

...
$possibilities = taxonomy_term_load_multiple(.., array('name' => trim($typed_term), …)
...

Which can return several terms with the same spelling. Then the function _i18n_taxonomy_autocomplete (i18n_taxonomy.pages.inc) which returns the autocomplete suggestions, returns an array keyed by term names, this has the side effect of reducing results where terms with the same name are condensed as one.

After the autocomplete process, the submission part of the form is responsible for saving the relations, but as you can imagine, this creates relations between terms which are completly wrong and leading to hours of "what the f*ck is going on there?!"

How to reproduce

  • setup a vocabulary to I18N_MODE_TRANSLATE,
  • have severals languages enabled (of course),
  • have a hierarchical vocabulary structure (not mandatory but easier to understand).

Example vocabulary:

(en)              (fr)
- Cars          - Voitures
-- Wheel        -- Roue
-- Structure    -- Structure
-- Break        -- Frein

- Bikes         - 2 roues
-- Wheel        -- Roue
-- Structure    -- Structure
-- Break        -- Frein

- Boat          - Bateau
-- Structure    -- Structure

In the translate interface you can't guess which Wheel or which Structure you are linking to.

Proposed resolution

I attach an emergency patch which converts the UI to let users type (autocomplete removed) a tid, which is the only trustable data to link translations. Please note that this patch is quick and dirty, as my goal was to have something that work, fast due to project deadline.

CommentFileSizeAuthor
i18n_taxonomy.diff5.75 KBjchatard

Comments

jose reyero’s picture

Title: Translate terms is broken » Translate terms autocomplete not working for terms with duplicated names.
Category: bug » feature
Status: Active » Needs work

Though I understand the issue, I think this is just consistent with Drupal core behavior for taxonomy autocomplete fields.

Duplicated term names won't work for tagging either (?)

So maybe the solution is to have some option (that may be a hidden variable) to turn the autocomplete into a drop down.

Or maybe it is not using duplicated term names at all?

jose reyero’s picture

Priority: Major » Minor