Community Documentation

Configure Pathauto to work with language-specific path aliases

Last updated May 20, 2013. Created by EvanDonovan on April 13, 2011.
Edited by LeeHunter, frederickjh, wmostrey, drewish. Log in to edit this page.

To configure Pathauto to have language-specific path aliases, do the following:

  1. admin/build/modules: enable Locale and Content Translation modules
  2. admin/build/block: enable the language switcher block (this is required since your path aliases will only show in the currently active language, the rest will show as unaliased)
  3. admin/settings/language/add: add a couple of new languages - say French and Spanish
  4. admin/settings/language/configure: change the 'Language negotiation' setting to 'Path prefix with language fallback'
  5. admin/content/types: edit the content types that require translation and set the 'Multilingual support' setting to 'Enabled, with translation' - the setting is in the 'Workflow settings' fieldset
  6. admin/build/path/pathauto: add new, language-specific patterns for the node types, say article/[title-raw] for French and artículo/[title-raw] for Spanish
  7. node/add/story: create a new item of content, and set the language to English (or whatever your default language is)
  8. node/NID/translate: click the Translate tab and then click the 'add translation' link for each language that you wish to have a translation

The big thing to keep in mind here is that for the paths are per language so for them to work you'll need to switch languages. Thus the language switcher block is required. If everything is set up right clicking on the Spanish link should take you to 'artículo/' and the French link 'article/', when you are in the respective languages.

Comments

The automatic behaviour of pathauto with content translation (or Internationalization) only matches the need of sites where you have total translation of all content and only language specific content is shown according to the language selected, so that if you choose Spanish, only Spanish content is visible to you, if you choose English, only English nodes are shown to you, etc.

This is OK and perfect for brochure, institutional and informative websites, but does not match the needs of most multi-language sites with dynamic, user-generated or multiple user contributed content. As it is designed today, it creates a path only for the language that matches the language of the node being aliased. This means that if I have Spanish selected as interface and click on an option to open an English document, I will get "node/xxx" because there is no alias for the node in English when visualizing it with Spanish language selected.

You can of course always go the list of Aliases, and manually switch each generated alias to "All languages". But you would have to do this every time a new content is generated, which is unrealistic for collaborative sites and tiresome for sites where you will be adding plenty of content, requiring 3 additional steps for each content added (go to URL Aliases, click on Edit alias, switch to All Languages and then submit).

Module neutral_paths by akamaus provides the behaviour most of us running dynamic multi-language sites require. It converts all existing paths to neutral language and makes sure new paths generated are neutral as well so that they work on every language.

For those who still don't get what the problem is, it is very basic: On a multilingual site, say English and Spanish, content on both languages should be visible to the user regardless of the interface or personal language choice the user makes. So if you are reading an article in Spanish and see the link at the bottom to see its English version, clicking on it should open the path alias of the English version (not node/xx) regardless of the interface language or user language of choice.

For example (real life example), on a website for a public figure, there is a page with her bio in Spanish with the alias "info/biografia". We have translated the node to English and assigned it the alias "info/biography". Yes, they are visible as es/info/biografia and en/info/biography. But the most likely scenario is that someone reading the document or arriving to it from Google, clicks on the English link. Normal behaviour takes the user to the English translation without switching languages and opening node/xx because normal pathauto behaviour only creates a path for the language selected for the node and no path for the node in other languages.

This feature is a must have, a basic need to every site that allows switching the language of a content or navigating to its translation and does not rely exclusively on the block for switching languages.

See "Option to always force language = All?" at http://drupal.org/node/1234924 and try the minimalistic neutral_paths module available at http://drupal.org/sandbox/akamaus/1420990 to solve this.

------
Con paciencia y calma,
sube un burro a una palma

Relief 2.0 - http://www.relief20.com
Navidad Latina - http://www.navidadlatina.com