You are here

private static function CustomLanguageManager::getLanguageConfigurationOptions in Custom Language field 8

Helper function to get special languages.

The following values are copied from LanguageConfiguration::getDefaultOptions() The following evaluations are copied from function language_get_default_langcode()

array('@language' => \Drupal::languageManager()->getDefaultLanguage()->name)),

  • 'current_interface' => t('Current interface language'),
  • 'authors_default' => t("Author's preferred language"),

Parameters

string $code: Formatting hint.

Return value

array Array of key-value pairs.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 call to CustomLanguageManager::getLanguageConfigurationOptions()
CustomLanguageManager::allowedValues in src/Entity/CustomLanguageManager.php
Gets a list of allowed values.

File

src/Entity/CustomLanguageManager.php, line 271

Class

CustomLanguageManager
Defines the CustomLanguage entity.

Namespace

Drupal\languagefield\Entity

Code

private static function getLanguageConfigurationOptions($code) {
  $values = [];
  switch ($code) {
    case LanguageInterface::LANGCODE_SITE_DEFAULT:
      $values = [
        LanguageInterface::LANGCODE_SITE_DEFAULT => t("Site's default language", [
          '@language' => \Drupal::languageManager()
            ->getDefaultLanguage()
            ->getName(),
        ]),
      ];
      break;
    case 'current_interface':
      $values = [
        'current_interface' => t('Current interface language'),
      ];
      break;
    case 'authors_default':
      $values = [
        'authors_default' => t("Author's preferred language"),
      ];
      break;
    case CustomLanguageManager::LANGUAGEFIELD_LANGUAGES_CUSTOM:
      foreach (CustomLanguageManager::getCustomLanguages() as $key => $labels) {
        $values[$key] = $labels
          ->label();
      }
      break;
  }
  return $values;
}