Hi,

I had to patch i18n_taxonomy.module to make autocompletion work for me. I'll upload the patch right after this post.

Here's the problem and some words on the resolution:
I have configured a textfield to autocomplete on a 'per language terms' vocabulary. Once I start typing I got a JS error, because the AJAX callback returns an empty string.
The AJAX call looks like http://host//taxonomy/autocomplete//
In i18n_taxonomy.module the path "/taxonomy/autocomplete" is routet to 'i18n_taxonomy_autocomplete' by hook_menu_alter.
Here's where the problesm start: i18n_taxonomy_autocomplete() expects a vocabulary Object, a language code and the tags as input. But from the request we get a fieldname, some tags and no langcode.

My solution is to reroute '/taxonomy/autocomplete' to a tiny function which figures out the respective vocabulary and determines the language, and pass this info to i18n_taxonomy_autocomplete()

Determination of the language is easy in my case, because I can rely on i18n_language(). However I can imagine cases where the language depends on the context. (e.g. editing a french node in a german UI). So my fix is limited to some special cases.

Hope it helps someone out there anyway...

Cheers,
Georg

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

g.oechsler’s picture

here's the patch

g.oechsler’s picture

Ouch, some of the text got filtered. It should read something like:

The AJAX call looks like http://host/{langcode}/taxonomy/autocomplete/{fieldname}/{terms}

Jose Reyero’s picture

Status: Active » Fixed

Reworked that part, it should be working now.

Thanks for the patch though.

Status: Fixed » Closed (fixed)

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

floretan’s picture

Status: Closed (fixed) » Active
Issue tags: +di18nscb

While expanding the i18n_taxonomy tests I found out that autocomplete works for vocabularies with I18N_MODE_TRANSLATE, but not for those with I18N_MODE_LOCALIZE.

My exact case was a term in English (default language) with a translation saved for French. The English version is always used.

floretan’s picture

I18n_Taxonomy tests have been expanded. Failing tests for this issue are there in testTaxonomyTermLocalize(), but commented out.

Jose Reyero’s picture

I am not sure we should do autocomplete for 'localizable' terms. The thing is our data model needs a source term (in default language) for the string translation to work and we cannot have that for autocomplete.

So maybe we should fix this by disallowing tags for 'localizable' vocabularies. That unless someone has an idea to get these terms working with tags, that I haven't.

danielnolde’s picture

i'm working on this, and it looks like it chould work out.

Jose Reyero’s picture

The problem here is: even if you can make autocomplete work, when you create new terms you may not have the one in the default language to translate it later.

Jose Reyero’s picture

Title: Patching i18n_taxonomy to make autocompletion work (somehow) » Make taxonomy autocompletion work / tagging / block tagging ?
Status: Active » Postponed (maintainer needs more info)

So, unless someone can post a good functional description for this (what happens when) for this case, there's no point in coding. Postponing till we have a better idea.

Anyway, just to raise the issue, should we block using localicable vocabularies for tagging?

webflo’s picture

I think we should treat autocomplete (read operation) and free tagging (write operation) different. Autocomplete for localized terms should be possible.

Jose Reyero’s picture

@webflo,
Agree, though I'm not sure what is the use case for taxonomy autocomplete if not tagging.

webflo’s picture

Search content in views via exposed filters?

Jose Reyero’s picture

Category: bug » feature
Status: Postponed (maintainer needs more info) » Postponed

Ok, I don't think this will fit in this release, but patches welcomed for the future.

webflo’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev
Cyclodex’s picture

I am checking if there are some other possibilities to create tags also on other languages etc.
This one is pretty old, seems we should improve this somehow. I see the problematic and can try to define a idea/workflow.

Just want to be sure, if this is really not improved already, for example on D8?

I will have to research further, but wanted to ask this question for now here ;)

Cheers Cyclodex

balagan’s picture

I am having this problem too. I use vocabulary in I18N_MODE_LOCALIZE mode. In my use case I dont want to add new terms, I just want to select from existing ones in latin language. The Select list widget shows translated terms, whereas the autocomplete widget uses the default language. I just want to point out, there are use cases when you dont want to save new terms, just want to use autocomplete instead of select lists containing thousands of words. Maybe implementing a new widget like Autocomplete term widget (select only) would solve this problem, and that way users could change whatever behaviour they want.

Cyclodex’s picture

I finally took the time to investigate the issue with LOCALIZED Taxonomies and have a working solution for myself.
I will need to clean up a a bit and separate the code into a module, to show you guys what I did. Perhaps it helps someone out there.