You are here

protected function UserAgentTest::getLanguages in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Utility/UserAgentTest.php \Drupal\Tests\Component\Utility\UserAgentTest::getLanguages()

Helper method to supply language codes to testGetBestMatchingLangcode().

Return value

array Language codes, ordered by priority.

1 call to UserAgentTest::getLanguages()
UserAgentTest::testGetBestMatchingLangcode in core/tests/Drupal/Tests/Component/Utility/UserAgentTest.php
Tests matching language from user agent.

File

core/tests/Drupal/Tests/Component/Utility/UserAgentTest.php, line 24

Class

UserAgentTest
Tests bytes size parsing helper methods.

Namespace

Drupal\Tests\Component\Utility

Code

protected function getLanguages() {
  return [
    // In our test case, 'en' has priority over 'en-US'.
    'en',
    'en-US',
    // But 'fr-CA' has priority over 'fr'.
    'fr-CA',
    'fr',
    // 'es-MX' is alone.
    'es-MX',
    // 'pt' is alone.
    'pt',
    // Language codes with more then one dash are actually valid.
    // eh-oh-laa-laa is the official language code of the Teletubbies.
    'eh-oh-laa-laa',
    // Chinese languages.
    'zh-hans',
    'zh-hant',
    'zh-hant-tw',
  ];
}