class LanguageLocaleMapper in Lingotek Translation 4.0.x
Same name and namespace in other branches
- 8 src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper
- 8.2 src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper
- 3.0.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper
- 3.1.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper
- 3.2.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper
- 3.3.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper
- 3.4.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper
- 3.5.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper
- 3.6.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper
- 3.7.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper
- 3.8.x src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper
Hierarchy
- class \Drupal\lingotek\LanguageLocaleMapper implements LanguageLocaleMapperInterface
Expanded class hierarchy of LanguageLocaleMapper
1 string reference to 'LanguageLocaleMapper'
1 service uses LanguageLocaleMapper
File
- src/
LanguageLocaleMapper.php, line 8
Namespace
Drupal\lingotekView source
class LanguageLocaleMapper implements LanguageLocaleMapperInterface {
/**
* The Entity Type Manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a new LingotekConfigTranslationService object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritDoc}
*/
public function getConfigurableLanguageForLocale($locale) {
$drupal_language = NULL;
$locale = str_replace("-", "_", $locale);
$id = $this->entityTypeManager
->getStorage('configurable_language')
->getQuery()
->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;
}
/**
* {@inheritDoc}
*/
public function getLocaleForLangcode($langcode) {
/** @var \Drupal\language\ConfigurableLanguageInterface $config_language */
$config_language = ConfigurableLanguage::load($langcode);
$locale = NULL;
if ($config_language) {
$locale = $config_language
->getThirdPartySetting('lingotek', 'locale', LingotekLocale::convertDrupal2Lingotek($langcode));
}
return $locale;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LanguageLocaleMapper:: |
protected | property | The Entity Type Manager service. | |
LanguageLocaleMapper:: |
public | function |
Gets the Drupal language for the given Lingotek locale. Overrides LanguageLocaleMapperInterface:: |
|
LanguageLocaleMapper:: |
public | function |
Gets the Lingotek locale for the given Drupal langcode. Overrides LanguageLocaleMapperInterface:: |
|
LanguageLocaleMapper:: |
public | function | Constructs a new LingotekConfigTranslationService object. |