You are here

public function ConfigurableLanguageManager::getNativeLanguages in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/language/src/ConfigurableLanguageManager.php \Drupal\language\ConfigurableLanguageManager::getNativeLanguages()

Returns a list of languages set up on the site in their native form.

Return value

\Drupal\Core\Language\LanguageInterface[] An associative array of languages, keyed by the language code, ordered by weight ascending and name ascending.

Overrides LanguageManager::getNativeLanguages

File

core/modules/language/src/ConfigurableLanguageManager.php, line 331
Contains \Drupal\language\ConfigurableLanguageManager.

Class

ConfigurableLanguageManager
Overrides default LanguageManager to provide configured languages.

Namespace

Drupal\language

Code

public function getNativeLanguages() {
  $languages = $this
    ->getLanguages(LanguageInterface::STATE_CONFIGURABLE);
  $natives = array();
  $original_language = $this
    ->getConfigOverrideLanguage();
  foreach ($languages as $langcode => $language) {
    $this
      ->setConfigOverrideLanguage($language);
    $natives[$langcode] = ConfigurableLanguage::load($langcode);
  }
  $this
    ->setConfigOverrideLanguage($original_language);
  Language::sort($natives);
  return $natives;
}