Maps local language to remote language.
string $language: Local language code.
string Remote language code.
Overrides TranslatorInterface::mapToRemoteLanguage
public function mapToRemoteLanguage($language) {
if (!$this
->providesRemoteLanguageMappings()) {
return $language;
}
$mapping = $this
->get('remote_languages_mappings');
$remote_languages = $this
->getSupportedRemoteLanguages();
if (!empty($mapping) && array_key_exists($language, $mapping)) {
if (empty($remote_languages) || array_key_exists($mapping[$language], $remote_languages)) {
return $mapping[$language];
}
}
$default_mappings = $this
->getPlugin()
->getDefaultRemoteLanguagesMappings();
if (isset($default_mappings[$language])) {
return $default_mappings[$language];
}
if ($matching_language = \Drupal::service('tmgmt.language_matcher')
->getMatchingLangcode($language, $remote_languages)) {
return $matching_language;
}
return $language;
}