class LanguageLocaleMapper in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 src/LanguageLocaleMapper.php \Drupal\lingotek\LanguageLocaleMapper
- 4.0.x 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 11
Namespace
Drupal\lingotekView source
class LanguageLocaleMapper implements LanguageLocaleMapperInterface {
/**
* The entity query factory service.
*
* @var \Drupal\Core\Entity\Query\QueryFactory
*/
protected $entityQuery;
/**
* Constructs a new LingotekConfigTranslationService object.
*
* @param \Drupal\Core\Entity\Query\QueryFactory $entity_query
* The entity query factory.
*/
public function __construct(QueryFactory $entity_query) {
$this->entityQuery = $entity_query;
}
/**
* {@inheritDoc}
*/
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;
}
/**
* {@inheritDoc}
*/
public function getLocaleForLangcode($langcode) {
/** @var 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 query factory 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. |