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
Project information
- Module categories: Multilingual, Developer Tools
- 242 sites report using this module
- Created by Pol on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Development version: 8.x-2.x-dev updated 22 Nov 2023 at 17:47 UTC
Development version: 7.x-2.x-dev updated 30 Nov 2016 at 13:48 UTC