Drupal offers great multilanguage possibilities for your website. Drupal core already offers a way to translate the website interface AND your content (nodes) in multiple languages. Enabling multiple languages is a piece of cake and translating content is made very simple. However, you need to perform some extra tricks to get the full interface translated. For example: you might want to translate your taxonomy terms and your menu items as well. Or, also very common, using some blocks or menu-items just for a single language only. One of the great community modules that helps you achieving this goal is the Internationalization module (i18n for friends).
In the past years, I've made several multi-language websites. And until today, I never found a good way to translate paths made by the Views module. For example: if you have an path like
www.domain.com/news, you'd probably want the translated versions to be
www.domain.nl/nieuws (Dutch) and
www.domain.fr/nouvelle (French), instead of
I used Google a lot, but never found a good solution. In the past, I always made a copy of my existing views, and entered a specific path for each language. Which made maintenance a crime, as every update to the views now should be done once for each language. That ended today, as I spotted this comment by our beloved merlinofchaos (the author of Views, Panels and Choas Tools), in which he said you just could use the default Drupal core module URL alias for this.
And it worked! Really.. I thought I've tried it before in the past without success, but to no avail. So easy, and so useful.
So.. what should you do to use one Page View for several paths? Easy:
- Switch to the english interface (good practice if your not a native English speaker): ALWAYS create strings in English and translate them afterwards. Even if you don't plan to use more languages that your own: you might change your mind in the future, and then you're screwed.
- Create a Page View and enter the Title and Path in English. Eg: Latest news and 'updates/news'.
- Save your view
- Navigate to your newly created view, so Drupal adds the strings to the translation table.
- Then go to Admin > Site Building > URL aliases (admin/build/path) and click Add alias
- In Existing system path, enter the URL you just created (eg updates/news).
- In Path alias, enter the URL you want in the other language (eg actueel/nieuws for Dutch).
- Make sure you set the language to the adjoining language (eg Dutch) and press Create new alias.
- Repeat the last three steps for every language
That's all it takes to create multiple URLs for each language! No need to create multiple views, no need to create your own module, and no need to fiddle with hooks, theme functions or hook_menu_alter. Merlin: I owe you a beer @ DrupalCon CPH! Thanks mate for being so helpful on all those issues!