You are here

public function OnlyOne::getLanguageLabel in Allow a content type only once (Only One) 8

Returns the language label.

Parameters

string $language: The language code.

Return value

string The language label.

Overrides OnlyOneInterface::getLanguageLabel

1 call to OnlyOne::getLanguageLabel()
OnlyOne::addAditionalInfoToContentTypes in src/OnlyOne.php
Add additional information to the content types.

File

src/OnlyOne.php, line 169

Class

OnlyOne
Class OnlyOne.

Namespace

Drupal\onlyone

Code

public function getLanguageLabel($language) {
  switch ($language) {
    case LanguageInterface::LANGCODE_NOT_SPECIFIED:
    case '':

      // If the language is empty then is Not specified.
      return $this->languageManager
        ->getLanguage(LanguageInterface::LANGCODE_NOT_SPECIFIED)
        ->getName();
    case LanguageInterface::LANGCODE_NOT_APPLICABLE:
      return $this->languageManager
        ->getLanguage(LanguageInterface::LANGCODE_NOT_APPLICABLE)
        ->getName();
    default:
      return ucfirst($language);
  }
}