You are here

public function GlobalLinkTranslator::getSupportedTargetLanguages in GlobalLink Connect for Drupal 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/tmgmt/Translator/GlobalLinkTranslator.php \Drupal\globallink\Plugin\tmgmt\Translator\GlobalLinkTranslator::getSupportedTargetLanguages()

Returns all available target languages that are supported by this service when given a source language.

Parameters

TranslatorInterface $translator: The translator entity.

$source_language: The source language.

Return value

array An array of remote languages in ISO format.

Overrides TranslatorPluginBase::getSupportedTargetLanguages

File

src/Plugin/tmgmt/Translator/GlobalLinkTranslator.php, line 629

Class

GlobalLinkTranslator
GlobalLink translation plugin controller.

Namespace

Drupal\globallink\Plugin\tmgmt\Translator

Code

public function getSupportedTargetLanguages(TranslatorInterface $translator, $source_language) {
  $results = [];
  $language_pairs = $translator
    ->getSupportedLanguagePairs();
  foreach ($language_pairs as $language_pair) {
    if ($source_language == $translator
      ->mapToRemoteLanguage($language_pair['source_language'])) {
      $target_language = $language_pair['target_language'];
      $results[$target_language] = $target_language;
    }
  }
  return $results;
}