Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

User Account Language Negotiation

423 sites Security covered Drupal 8–11
View on drupal.org

This module enhances language handling for Drupal users by automatically saving their preferred language when they switch it, displaying language names in their native translations, and seamlessly transitioning users to their previously selected language upon login.

This module does three things differently from Drupal core:

  1. Automatically saves the user's preferred language when they switch languages.
  2. Displays language names in their native translations ("Español" instead of "Spanish"). What this means is visible in the picture to the right.
  3. Seamlessly transitions to the user's previously preferred language during login.

You need this module only if your multilingual site has users that are typically logged in.

Requirements

  • PHP 7.0 or higher
  • Drupal core version 8 - 12
  • A Drupal site with more than one language enabled

Installation

  1. Download the module. I suggest using Composer: composer require 'drupal/user_account_language_negotiation:^1.0'
  2. Enable the module, e.g. using drush en user_account_language_negotiation

Configuration

  1. Go to Detection and selection (/admin/config/regional/language/detection).
  2. Uncheck all plugins except this module's User account saver. Only if User account saver is the only enabled plugin we can be sure we manage the transition to the user's previously preferred language during their login.
  3. Make sure your users have a way of switching the language. If you haven't set up anything yet, you can visit the block list page (/admin/structure/block) and add Drupal Core's "Language switcher" block.

Inner workings

Technically speaking, this module just supplies a LanguageNegotiation plugin. It leaves the visual part of picking a language to other modules. A typical setup is to use Core's "Language switcher" block, optionally in conjunction with the Language Icons module. The picture above is from this setup.

This module acts in 3 situations:

  1. When the user opens a page, Drupal needs to know which language the page should be rendered in. If you are curious, see the getLangcode() function in the code.
  2. When the user just switched the language: save it in his or her account (processInbound()).
  3. When the language switcher block needs to know which languages exist (getLanguageSwitchLinks()).

Similar modules

  • Language Cookie remembers the visitor's language choice in a browser cookie instead of the user account. This also works for anonymous visitors, but the preference doesn't follow the user to a different browser or device the way an account-based preference does.

Maintainer

Support

To submit bug reports and feature suggestions, or to track changes, use the issue queue.

To say "thank you" or financially support development of this module, you can send a few Euros via PayPal: [email protected] or various other means.

Depends on

Dependencies of the latest stable release

  • language Drupal core
  • locale Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Sep 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Slowing

Releases

Version Type Core Release date
8.x-1.8 Stable 8–11 Apr 21, 2025
8.x-1.7 Stable 8–11 Sep 28, 2024