Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LanguageNegotiationUserAdmin.php

function LanguageNegotiationUserAdmin::getLangcode

Overrides LanguageNegotiationMethodInterface::getLangcode

File

core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php, line 102

Class

LanguageNegotiationUserAdmin
Identifies admin language from the user preferences.

Namespace

Drupal\user\Plugin\LanguageNegotiation

Code

public function getLangcode(?Request $request = NULL) {
    $langcode = NULL;
    // User preference (only for administrators).
    if (($this->currentUser
        ->hasPermission('access administration pages') || $this->currentUser
        ->hasPermission('view the administration theme')) && ($preferred_admin_langcode = $this->currentUser
        ->getPreferredAdminLangcode(FALSE)) && $this->isAdminPath($request)) {
        $langcode = $preferred_admin_langcode;
    }
    // Not an admin, no admin language preference or not on an admin path.
    return $langcode;
}
RSS feed
Powered by Drupal