I have a multilingual site that uses Entity Translation to translate entities, in this case taxonomy terms.

I have a taxonomy term page view with one argument for the term id (taxonomy/term/%). I have enabled the option that overrides the title, and I've configured the override to use the first argument, %1.

This causes the name of the taxonomy term to be used as the title for the view. So far so good.

However, this won't display the term name in the users current language. I have searched through the code, and I've noticed that this is happening because the argument is being validated. In the views_plugin_argument_validate_taxonomy_term class, there is a function called validate_argument(). This will load some taxonomy term data straight from the database, and will set $this->argument->validated_title to the name that exists in the database. This way, the get_title() function in the views_handler_argument class will return the validated_title variable instead of executing the title() function from the views_handler_argument_taxonomy class.

So, the problem occurs because the argument validator is loading values straight from the database, which I guess is related to performance reasons. But that messes up the title. One solution would be to simply not set the validated_title variable which would fire the appropriate get_title() function.

Comments

olofbokedal’s picture

Status: Active » Needs work
StatusFileSize
new1.52 KB

This patch changes the behavior for the tid and tids argument validators.

dawehner’s picture

Status: Needs work » Fixed

This patch simply can't land in views, you know this would break quite a lot of sites, as they rely on the title.

So what you actually want to do is to implement a custom argument handler on the module which implements the taxonomy translation. As far as i understand entity translation it is actually a field translation so the name is translated different. I guess you use i18n here as well.

They provide proper argument handlers so things work as expected.

olofbokedal’s picture

So for this to work, I'd have to use both Entity translation and i18n? Wouldn't that require me to translate the term name in two different places?

olofbokedal’s picture

Status: Fixed » Active
dawehner’s picture

Project: Views (for Drupal 7) » Internationalization Views
Version: 7.x-3.3 » 7.x-3.x-dev

Well it's definitive not an issue of views, as it doesn't know something of i18n/entity translation.

Afaik i18nviews should support both translation and internationalization of the terms.

webflo’s picture

Category: bug » support
Status: Active » Fixed

i18n Views provides specific argument validators for single and multiple tids. This should work. Look at the example in #1541924: Title not translated (i18n) in the standard "taxonomy term view"

Status: Fixed » Closed (fixed)

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