2

I use a view to show a list of nodes flagged by a global flag (any user, any language) and would like to return only current language related nodes.

For that I should be able to add a filter in the View which is something like "Content Translation: Language". However no such filter seems to be available. Any idea why this filter is missing?

1

To make the view results correspond to the language switcher, add a filter for Content Translation: User's Current Language, which is the language that an authenticated user has set in the user settings (it is NOT the same as the current browser language or the site language).

If no option for the 'User's Current Language' is available in the filter criteria form, then verify your configuration at Configuration -> Languages -> detection and selection: the order should be 'URL, Default, User', and not something like 'Default, URL, User' (as mentioned also in https://www.drupal.org/node/1701854#comment-6279474).

Note: filtering Views results in a multi language site can sometimes be challenging, as illustrates also in discussions such as in https://groups.drupal.org/node/47478 ...

  • thank you again sir, that's work for me but not correctly , it work in the content product only , and i want it work in the front page , can you help me more please , and i'm so sorry about my very bad language ! – SeifBh May 15 '15 at 14:17
  • yes something like that , but I published another questions more clear drupal.stackexchange.com/questions/158537/… I tried several times to do that but I have not solved this problem – SeifBh May 15 '15 at 15:16
  • 1
    Yes i have the filter in the slideshow view Content : language (Current user's language) – SeifBh May 15 '15 at 15:36
  • Great, so there is progress on "this" question. Please briefly explain "how you got that part to work". to do so, either add that explanation as a comment to the answer that helped you to get it to work (and mark that answer as accepted). Maybe (if you want) also upvote that answer. If the solution was something else (different from both answers), then add a new answer to briefly describe it, and mark that answer as "accepted". From then on we can "forget" about this answer (and continue with either of the 2 other questions). That's part of how Drupal Answers works, ok? – Pierre.Vriens May 15 '15 at 15:53
  • OK, I already did that, but can I explain later – SeifBh May 15 '15 at 15:58
3

Between the filters you should see 'Content Translation: User's Current Language'. Also check out the Internationalization Views module for more translation options for views.

Translate views using Internationalization. This is a work in progress and not all Views properties can be translated yet.

This module has been moved from Internationalization package so we can have different branches compatible with each of the Views versions. Use the same branch of the Views version you are using (2.x. 3.x).

  • I think that i18nviews can "only" translate labels, buttons of exposed filters etc. in views, see the instructions. However, the description in admin/modules reads: "Translation of views strings and content selection for views." That could mean "content selection behaviour" or "[translation of] content selection filter labels", so I'm not totally sure. – tanius Jul 21 '16 at 20:54
0

It happens when you have Entity Translation enabled in parallel.

The "Content Translation: Language" filter is missing from Views if you have enabled both Content Translation (module translation, in Drupal 7 Core) and Entity Translation (module entity_translation, a contrib project). There is also a this Views issue dealing with this situation, and there also the environment had both translation systems enabled.

This is normally not meaningful as these two systems are meant as alternatives to each other, with Entity Translation being the more modern one. However, in some special cases it can be meaningful (like, handling some legacy node types with Content Translation, new node types with Entity Translation).

Solution alternatives:

  • Use Select Translation. This module is specifically made for Content Translation and provides a Views filter "Content Translation: Select translation" that provides the same possibilities as the missing "Content Translation: Language" one, plus more freedoms to configure fallback behaviour.

  • Disable Entity Translation. This alternative should give you the "Content Translation: Language" filter with its fallback behaviour. Perhaps disabling is not enough though and you'll have to uninstall the entity_translation module as well (see here for a similar but reverse situation).

  • Use "Content: Language" (usually not applicable). When Entity Translation is enabled, on its own or additionally, it provides a Views filter "Content: Language" (as also found by the OP). It provides the same configuration options as "Content Translation: Language" and can also filter nodes for which you use Content Translation. However, it does not know about the "translation set" concept of Content Translation, so the Views result can contain multiple translations of the same content (unlike when using it with Entity Translation nodes). For that reason, it is only a solution if you allow only one value to pass the filter, like by setting it to "Content: Language (= Current user's language)". Also unlike the "Content Translation: Language" filter, this filter does not provide a fallback to the site's default language.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.