You are here

public function LanguageLocaleMapper::getConfigurableLanguageForLocale in Lingotek Translation 8

Same name and namespace in other branches
  1. 8.2 src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper::getConfigurableLanguageForLocale()
  2. 4.0.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper::getConfigurableLanguageForLocale()
  3. 3.0.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper::getConfigurableLanguageForLocale()
  4. 3.1.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper::getConfigurableLanguageForLocale()
  5. 3.2.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper::getConfigurableLanguageForLocale()
  6. 3.3.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper::getConfigurableLanguageForLocale()
  7. 3.4.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper::getConfigurableLanguageForLocale()
  8. 3.5.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper::getConfigurableLanguageForLocale()
  9. 3.6.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper::getConfigurableLanguageForLocale()
  10. 3.7.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper::getConfigurableLanguageForLocale()
  11. 3.8.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper::getConfigurableLanguageForLocale()

Gets the Drupal language for the given Lingotek locale.

Parameters

string $locale: The Lingotek locale.

Return value

ConfigurableLanguageInterface|NULL The Drupal language created for this locale, or NULL if there is none.

Overrides LanguageLocaleMapperInterface::getConfigurableLanguageForLocale

File

src/LanguageLocaleMapper.php, line 33

Class

LanguageLocaleMapper

Namespace

Drupal\lingotek

Code

public function getConfigurableLanguageForLocale($locale) {
  $drupal_language = NULL;
  $locale = str_replace("-", "_", $locale);
  $id = $this->entityQuery
    ->get('configurable_language')
    ->condition('third_party_settings.lingotek.locale', $locale)
    ->execute();
  if (!empty($id)) {
    $drupal_language = ConfigurableLanguage::load(reset($id));
  }
  else {
    $drupal_language = ConfigurableLanguage::load(LingotekLocale::convertLingotek2Drupal($locale));
  }
  return $drupal_language;
}