Hi,

I am using an exposed filter to select rows that are of a type only. I have translated the node type names, using the Translation Interface, and I can see these translations working elsewhere.

Though, the content type names in the exposed filter are not translated.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jmix’s picture

different issue but it can be related: content-type names are only translated in the admin pages, impossible to print it in a view or a node...

bart.hanssens’s picture

Seems to work (using latest git version + views 3.x-dev + i18n 1.x-dev + variable 2.x-dev)

Frando’s picture

Status: Active » Needs review
FileSize
3.72 KB

This is indeed not possible at the moment: In views, the node type labels in exposed forms and as a field are translated with t(). This is bad, because node type labels are user defined strings and therefore need special handling and not just t().

The attached patch fixes this.

It copies the node type field and filter handlers over to i18nview and properly translates the node type label there. The new handlers are registered in place of the default handlers, so it works without changing the concerned views (caches have to cleared, of course).

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

This is really looking fine in terms of views code!

Even I haven't tried the code, but that is RTBC, when you don't consider the 100% strict core documentation/code style requirements.

Nicolas Bouteille’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work

Hi,

I just carefully applied the patch manually and it did not work. The filter by content type said its handler was broken. Since this code dates from Feb 2013 and it is now May 2014 this might be due to changes in Views making this code break now. Which also means this patch is not suited for the long run...

By the way, how come this RTBC patch never got committed?

cs_shadow’s picture

Issue tags: +Needs reroll

Since it was never committed, this patch needs a reroll against latest HEAD.

ptmkenny’s picture

FileSize
3.63 KB

Re-rolled against HEAD. All credit should go to original submitter.

ptmkenny’s picture

Status: Needs work » Needs review
webflo’s picture

Status: Needs review » Needs work
Issue tags: -Needs reroll

i18nviews provides additional views handlers. We do not overwrite existing views handler to avoid conflicts with contrib. Please follow this pattern. Check out i18nviews_views_data_alter_i18n_taxonomy for examples.

pfournier’s picture

FileSize
4.78 KB

Adding the handlers, instead of overwriting them.
Added a node type argument handler.

pfournier’s picture

Status: Needs work » Needs review
devad’s picture

Status: Needs review » Reviewed & tested by the community

I have applied patch (manually), and it works.

The new "Content: Type (translated)" option is available in both fields list and filters list, and they both works as expected.

It would be nice to have this commited.

  • webflo committed dae921b on 7.x-3.x authored by pfournier
    Issue #1687752 by pfournier, ptmkenny, Frando, webflo: Translate node...
webflo’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @pfournier and @devad for the final patch/review.

Status: Fixed » Closed (fixed)

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

kbrinner’s picture

It looks like this patch has been committed to the alpha1 branch but I don't see any option in the Translation Interface at admin/config/regional/translate/translate to translate content type names. If I search for 'Articles', one of my content types, I don't see anything under "Content: Type (translated)" or any possible string that would relate to a Views exposed filter or a content type name. I have il8n_views (v7.x-3.0-alpha1) enabled and have been translating most of my views successfully.

Other translation modules that are enabled:
entity_translation
i18n_field
i18n_menu
i18n_panels
i18n_string
i18n_translation
locale

Is there something else that should be enabled or what am I missing?

devad’s picture

@kbrinner

This issue is about exposed views filters.

You have problem translating content type names with Entity Translation.

Try to "google" for: "entity translation" "content type" name

kbrinner’s picture

That is what I was asking about - I have exactly the same issue as the original post:

I am using an exposed filter to select rows that are of a type only. I have translated the node type names, using the Translation Interface, and I can see these translations working elsewhere.

Though, the content type names in the exposed filter are not translated.

devad’s picture

FileSize
173.64 KB

@kbrinner

I am not sure I understand your issue completely, but I will try to help.

From your first post I could understand that you were expecting to find "Content: Type (translated)" option at admin path: admin/config/regional/translate/translate.

However, this is not the place where "Content: Type (translated)" option is added. It is added inside the views "Add fields" and "Add filter criteria" sections.

Please, see attached image. Beside standard "Content: Type" option i18n_views module now adds a new "Content: Type (translated)" option as well. Both are marked red in image.

Do you have these two options available inside your view?

kbrinner’s picture

FileSize
172.66 KB

OH. @devad thank you for taking the time to explain. I do have the option available inside my view for Content: Type (translated). I misunderstood where you were supposed to see that option. THANK YOU.
type translated

devad’s picture

@kbrinner

You are welcome.