Instead of directly displaying taxonomy terms with $term->name, Views should use entity_label('taxonomy_term', $term).
i18n_taxonomy.module for example automatically integrates with that to show the translated term title, if available.
This should make i18nviews's life easier and could probably deprecate a number of taxonomy handlers which do nothing else but display the term title in the correct language. And it should also make it much easier for users. Had to dive really deep into the views code to understand that I also need the i18n term argument validation handler because that one does inject the validated title ;)
Needs more testing, but seemed to work for me. Most $term's are actually not loaded with taxonomy_term_load() but use custom queries, that's a bit.. unfortunate but works in 7.x.
Consider this as a proof of concept :)
Comment | File | Size | Author |
---|---|---|---|
#6 | views-entity_label-1864870-6.patch | 2.21 KB | Andrew Answer |
|
Comments
Comment #1
BerdirBetter patch, still had a $term->name in there.
Comment #2
dawehnerThanks for working on it!
I don't want to change these things in d7 unless we have tests for it, but in general your changes looks fine. For d8 we either have fixed it already or there are issues for that.
Comment #3
dawehnerShould we ever call entity_label on an entity which is not loaded totally?
Comment #4
BerdirRe-roll, looks like one file was already fixed.
One case remaining where we don't load the entity. Not sure if we should load or not.
Comment #5
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 5 year old patch in #4 does not apply to the latest views 7.x-3.x-dev and if still applicable needs reroll.
Comment #6
Andrew Answer CreditAttribution: Andrew Answer as a volunteer commentedPatch rerolled.
Comment #7
AlfTheCat CreditAttribution: AlfTheCat commentedAfter applying the patch, I get a fatal error and the taxonomy page breaks. I tried the latest views dev release and the latest stable release, both with the same result.
The error in the log:
EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 8003 of /var/aegir/platforms/[xxxx]/includes/common.inc).