Skip to main content

Reply to comment

It adds tokens for language

It adds tokens for language for pathauto to use, which allows one to circumvent the i18n module a bit.

Before this module, my pathauto for blog nodes was: [yyyy]/[mm]/[dd]/[title-raw], which makes pathauto make an alias like /2008/01/07/i18n-and-pathauto. However, when Drupal creates a link to that alias, i18n will step in, notice that there's no language prefix, and rewrite the path to include the language prefix. So if the current language is Danish, it'll change it to /da/2008/01/07/i18n-and-pathauto, and if the language is English, it'll make it /en/2008/01/07/i18n-and-pathauto.

Which will most likely case havoc when spiders starts trawling your site, as you end up with each node duplicated between 2 pathes.

The links will work fine, when /da/2008/01/07/i18n-and-pathauto is requested, i18n will strip the language, and look for an alias named /2008/01/07/i18n-and-pathauto. It will find it and the page will be displayed. But it's still in english.

Using this module, I've changed the pathauto setting to: [lang]/[yyyy]/[mm]/[dd]/[title-raw]. This will make pathauto generate an alias like /en/2008/01/07/i18n-and-pathauto (note the prefix), and when i18n does its thing, it'll notice that there's already a language prefix, and not change the link no matter what the language. And so the /da/2008/01/07/i18n-and-pathauto will never appear.

If there's no language set for a node, the [lang] token will be an empty string, which will be stripped by pathauto, with the result that language neutral nodes wont get a language prefix alias, and fall back to the default behaviour, being available under all prefixes.

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <pre>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Images can be added to this post.

More information about formatting options