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

Breadcrumb

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

function Request::getLanguageCombinations

Returns an array of all possible combinations of the language components.

For instance, if the locale is "fr_Latn_FR", this method will return:

  • "fr_Latn_FR"
  • "fr_Latn"
  • "fr_FR"
  • "fr"

Return value

string[]

1 call to Request::getLanguageCombinations()
Request::getPreferredLanguage in vendor/symfony/http-foundation/Request.php
Returns the preferred language.

File

vendor/symfony/http-foundation/Request.php, line 1626

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

private static function getLanguageCombinations(string $locale) : array {
    [
        $language,
        $script,
        $region,
    ] = self::getLanguageComponents($locale);
    return array_unique([
        implode('_', array_filter([
            $language,
            $script,
            $region,
        ])),
        implode('_', array_filter([
            $language,
            $script,
        ])),
        implode('_', array_filter([
            $language,
            $region,
        ])),
        $language,
    ]);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal