Enable language negotiation

Last updated on
7 September 2016

By default, Drupal includes support for language negotiation using a variety of methods. This means your site can offer multilingual content without forcing the user to choose their language before entering the site. There is no need to use a splash page to choose a language when you use Drupal!

The built-in methods for negotiating language are:

  • URL - Determine the language from the URL (Path prefix or Domain).
  • Session - Determine the language from a request/session parameter.
  • User - Follow the user's language preference.
  • Browser - Determine the language from the browser's language settings.
  • Default language - Use the default site language (English).

Language Detection and Selection UI

You can enable and re-order these methods through the 'Language Detection and Selection' user interface at Configuration > Regional and Language > Languages > Language Detection and Selection.

Generally, the URL method will be enabled and will be the first on the list, meaning that if the language is specified in the URL of the page, the page will be displayed in that language. The URL method can be configured to use either the domain or language path prefix of the page. If the language is not specified in the URL, the next method on the list will be used.

The default language is always enabled as a detection method and is usually the last enabled method, providing a fallback language if none of the other language detection methods are available.

In addition to the built-in methods of detection, it is possible to determine the user's language preference by creating your own custom or contributed modules, possible ideas:

  • Geolocation - Determine the user's language by where they are using latitude and longitude values.
  • LDAP - Similar to the built-in User method, but using LDAP as your data source.

You can also create your own method to determine the user's language using API methods that were introduced in Drupal 7.