Additional documentation for MultiLink

What's it for?

MultiLink is designed for multi-language sites. Please read the project page for a general description and example use cases. In short, it greatly simplifies management of in-content links to other content (nodes), especially for a site where not all content is available in all languages. Additionally, MultiLink can automatically redirect users to the correct language version of content when, for example, they follow a link elsewhere which would take them to content in a language other than their preferred language.

Path aliases

In many examples below, we refer to paths such as node/100 for simplicity, but in practice urls generated will always use the alias for that node, if defined.

Input Filter

MultiLink provides an input filter which allows you to create a link by entering something like [100: more information] which will be converted to: more information ... or a similar link to node/101 if that is the French version of node/100 and the user is browsing French content, or node/102 if that is the Spanish version and the user is browsing Spanish content, and so on. The title of the link (shown by the browser when hovering over the link) will be taken from the actual title of the target node.

Support for other input filters

MultiLink supports integration with other modules and methods of linking and including nodes in content. In effect it adds "multi-language link" functionality to:

To use these features, you will need to enable them on the configuration page for your filter format, and suitably configure filter order so that MultiLink processing takes place before other relevant filters such as InsertNode. In the cases of Markdown and HTML links, use relative paths starting /node e.g. /node/1234.

MultiLink Redirect sub-module

If installed, redirects requests to a node to the translated version (if available) which can be useful for people who arrive at your site via links on other sites (or even your own site, if not all links are generated by MultiLink). For example, if a user goes to en/node/123 but their preferred language (from browser or account settings) is French, then they will be redirected to fr/node/124 where node/124 is the French translation of node/123. In general, the user will end up at the same page/url that they would have arrived at if they had clicked a link generated by MultiLink.

MultiLink Redirect provides much of the functionality of Global Redirect but using the same rules and cached data used by the MultiLink Filter to determine which page (node) should be served (the exact behaviour of Global Redirect on a multi-language site is currently undefined - see [#201675].)

A permissions setting bypass multilink redirect allows the redirect to be disabled on a role basis, intended for use by admins and translation staff. A message is displayed showing the redirection that would have been performed, so this feature is useful for testing that the module is operating as anticipated.

Redirection of logged in users

In short, the system tries to redirect the user to the "best" url based on the user's language preference, determined by the user account setting if available, or otherwise by the user's browser configuration for preferred language.  The interface language (for menus, system messages, etc) will be chosen to match the user's preferred language, and the content (node) chosen will be in their preferred language if available, otherwise some other "best fit" language.
Examples
These examples assume a default configuration for MultiLink - the default preference order of various languages (from browser, user account, url, etc.) can be changed via a configuration setting.

Let's say that the user's preferred language is Italian, and no path aliases exist:
The examples above refer to paths such as node/123 for simplicity, but in practice the user will always be redirected to the alias for a node, if defined. 

Redirection of anonymous users

Behaviour depends on whether Drupal page caching is enabled or not. The page cache is normally only active for anonymous users.

Combination with Global Redirect

MultiLink Redirect has been tested with Global Redirect also installed and the combination found to operate acceptably. However, you may need to alter "weight" in the system table to obtain the desired results. MultiLink Redirect will redirect requests to a single alias (the alias returned by Drupal's url() function) and so this module alone may be adequate to avoid the SEO issues which Global Redirect is designed to address. However, Global Redirect provides other functionality (e.g. dealing with paths to taxonomy terms) so you may need both modules.

How does MultiLink generate urls?

The same process is used for generating urls whether for use as as link-targets or redirection targets.

Definitions:

First let's try to name some of the possible language choices that we have to deal with:
New in version 2.5, detection of when the user switches to a different language, for example using the standard Drupal language-switcher block. MultiLink subsequently regards the newly selected language as the user's preferred-language for the current browser session.

Behaviour:

Order of language selection

The default order can be changed (since version 2.5) in settings.php.  You can add a line in settings.php to control the order in which possible languages are selected.

D6 branch
e.g: $conf['multilink_language_order'] = array('selected', 'preferred', 'current', 'default');

If multilink_language_order is not defined the default order is: selected, preferred, current, default.  Note that the user's preferred-language referred to under Behaviour can be over-ridden here - the first of the languages defined by multilink_language_order will be used preferred-language.

D7 branch
As above except language names are in default order are now: selected, preferred, browser, current, content, url and default.
Note: Drupal's choice for current and content languages is in-turn determined by language detection and selection settings at admin/config/regional/language/configure.

Performance and caching

Standard Drupal page caching is supported for anonymous users. [*more detail needed - redirection may prevent a cached page from being served, and anonymous users may see a cached page containing links which do not point to the same nodes as they would in the same page non-cached.]

For logged-in users, or when page-caching is not enabled, there are further caching mechanisms:

The module uses a smart caching scheme to avoid performance degradation. For example, it caches links to translated versions of node/100, but if node/100 or a translation of it is added, edited or deleted then the relevant cache entries are cleared so that the generated links will be updated.

Optionally, and currently D6 only, you can enable additional caching by Drupal which will improve performance considerably for non-cached pages. As with page-caching, outdated links may be shown for 24 hours - for example when a new translation is added it will be used as a link or redirect target until the cache has expired. This is an advanced option and to be effective requires the following: