| Project: | Internationalization |
| Version: | 7.x-1.x-dev |
| Component: | Taxonomy |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed |
| Issue tags: | autocomplete, di18nscb |
Issue Summary
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
Comments
#1
here's the patch
#2
Ouch, some of the text got filtered. It should read something like:
The AJAX call looks like http://host/{langcode}/taxonomy/autocomplete/{fieldname}/{terms}
#3
Reworked that part, it should be working now.
Thanks for the patch though.
#4
Automatically closed -- issue fixed for 2 weeks with no activity.
#5
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.
#6
I18n_Taxonomy tests have been expanded. Failing tests for this issue are there in testTaxonomyTermLocalize(), but commented out.
#7
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.
#8
i'm working on this, and it looks like it chould work out.
#9
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.
#10
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?
#11
I think we should treat autocomplete (read operation) and free tagging (write operation) different. Autocomplete for localized terms should be possible.
#12
@webflo,
Agree, though I'm not sure what is the use case for taxonomy autocomplete if not tagging.
#13
Search content in views via exposed filters?
#14
Ok, I don't think this will fit in this release, but patches welcomed for the future.
#15
#16
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