Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#20 | type translated.png | 172.66 KB | kbrinner |
#19 | Untitled-3.jpg | 173.64 KB | devad |
#10 | i18nviews-translate_node_type-1687752-10.patch | 4.78 KB | pfournier |
Comments
Comment #1
jmix CreditAttribution: jmix commenteddifferent 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...
Comment #2
bart.hanssens CreditAttribution: bart.hanssens commentedSeems to work (using latest git version + views 3.x-dev + i18n 1.x-dev + variable 2.x-dev)
Comment #3
Frando CreditAttribution: Frando commentedThis 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).
Comment #4
dawehnerThis 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.
Comment #5
Nicolas Bouteille CreditAttribution: Nicolas Bouteille commentedHi,
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?
Comment #6
cs_shadow CreditAttribution: cs_shadow commentedSince it was never committed, this patch needs a reroll against latest HEAD.
Comment #7
ptmkenny CreditAttribution: ptmkenny commentedRe-rolled against HEAD. All credit should go to original submitter.
Comment #8
ptmkenny CreditAttribution: ptmkenny commentedComment #9
webflo CreditAttribution: webflo commentedi18nviews 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.
Comment #10
pfournier CreditAttribution: pfournier commentedAdding the handlers, instead of overwriting them.
Added a node type argument handler.
Comment #11
pfournier CreditAttribution: pfournier commentedComment #12
devad CreditAttribution: devad commentedI 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.
Comment #14
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedThanks @pfournier and @devad for the final patch/review.
Comment #16
kbrinnerIt 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?
Comment #17
devad CreditAttribution: devad commented@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
Comment #18
kbrinnerThat is what I was asking about - I have exactly the same issue as the original post:
Comment #19
devad CreditAttribution: devad commented@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?
Comment #20
kbrinnerOH. @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.
Comment #21
devad CreditAttribution: devad commented@kbrinner
You are welcome.