Returns the supported target languages for this translator.
string $source_language: The local source language.
array An array of supported target languages in ISO format.
Overrides TranslatorInterface::getSupportedTargetLanguages
public function getSupportedTargetLanguages($source_language) {
if ($plugin = $this
->getPlugin()) {
$info = $plugin
->getPluginDefinition();
if (isset($info['language_cache']) && empty($info['language_cache'])) {
// This plugin doesn't support language caching.
return $this
->mapToLocalLanguages($plugin
->getSupportedTargetLanguages($this, $this
->mapToRemoteLanguage($source_language)));
}
else {
// Retrieve the supported languages from the cache.
if (empty($this->languageCache) && ($cache = \Drupal::cache('data')
->get('tmgmt_languages:' . $this->name))) {
$this->languageCache = $cache->data;
}
// Even if we successfully queried the cache it might not have an entry
// for our source language yet.
if (!isset($this->languageCache[$source_language])) {
$local_languages = $this
->mapToLocalLanguages($plugin
->getSupportedTargetLanguages($this, $this
->mapToRemoteLanguage($source_language)));
if (empty($local_languages)) {
return [];
}
$this->languageCache[$source_language] = $local_languages;
$this
->updateCache();
}
}
return $this->languageCache[$source_language];
}
}