Skip to main content

Views and i18n

I just started working on my first multi-lingual site in Drupal this week (woo-hoo!), and ran into a minor issue with one of my views: both the English and Spanish versions of translated nodes were appearing in the view. No good!

Although I couldn’t find any documentation on how to filter a view based on a user’s language, it turned out to be super easy to do – so easy, in fact, that it’s barely worth a post. But I’m writing this for those of you who, like me, think that the logical place to start tweaking the view is under the arguments section. Turns out what I really wanted to do was to add a fliter.

Here’s how you do it:

  1. Edit your View.
  2. Add the “Node translation: Language” filter to your view.
  3. Select “Is one of” for the Operator and “Current user’s language” for the Language.

Lists of nodes that have been translated into more than one language will now only contain posts written in the current user’s language. Gravy.