Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Language Selection Page

Security covered Under active development 178 sites

This module provides a language selection landing page for websites, allowing visitors to choose their preferred language from enabled site languages. It's useful when you don't want to enforce a default language and can be customized through Drupal's theming system.

Description

This module allows you to present visitors of your website with a landingpage / splash page where they can select the language of their choice, based on the languages that have been enabled on your Drupal site.

This is useful in situations where you don't want to enforce a default language to users (e.g. because of political or corporate sensitivities) if they come to your website without a language preference available (url, cookie, ...)

The language selection page can be overridden through Drupal's template system.

It is recommended that you move the "Selection Page" language detection method near the bottom.
Preferably you need to have another method of detection activated above it, such as "URL" or "Cookie" (via the contrib module Language cookie), if you don't want to have users arrive on the language selection page too frequently.

Features

  • Provides an additional language negotiation fallback using an HTML selection page.
  • It can inject the HTML in the $content of a page or use it's own template that you can customize through the regular theming system.
  • Configure a set of blacklisted paths where the module shouldn't run on.

Tips

  • Try to set a prefix for all the enabled languages to get it working properly
  • You can change the layout of the page by creating a page: html--language-selection.tpl.php in your theme directory, copy the file html.tpl.php from the system module, you can access the new $language_selection_page variable, there's everything you need to customize the page in it.

Using it's API

You can use the hook: hook_language_selection_page_data_alter() to update data sent through the template. Exemple:

/**
 * Implements hook_language_selection_page_data_alter().
**/
function testmodule_language_selection_page_data_alter(&$data) {
  foreach ($data['links'] as &$item) {
    $link_text = _scramble_string("Continue in " . $item['language']->native);
    $item['link'] = l($link_text, $data['from']['text'], array('query' => $data['from']['query'], 'language' => $item['language']));
  }
}

function _scramble_string($string) {
  return preg_replace('/(\w+)/e', '_scramble_word("\1")', $string);
}

function _scramble_word($word) {
  if (strlen($word) < 2) {
    return $word;
  } else {
    return $word{0} . str_shuffle(substr($word, 1, -1)) . $word{strlen($word) - 1};
  }
}

This example will scramble the text displayed in the links in the template.

Related modules

  • Global redirect: Strongly advised, it redirects all URLs without a language prefix to the correct URL with the default language prefix contained.
  • Language cookie

Where is it used ?

Maintainers

  • Pol - Drupal 6, Drupal 7 and Drupal 8 version
  • svendecabooter - Drupal 7 version improvements
Drupal 10–11

Ask your assistant about Language Selection Page

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • locale Drupal core
  • path_alias Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Mar 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
3.0.x-dev Dev 10–11 Aug 13, 2024
3.0.0 Stable 10–11 Aug 13, 2024
8.x-2.12 Stable 9–10 Jan 22, 2024
8.x-2.11 Stable 9–10 Mar 3, 2023