public function SmartlingTranslator::getSupportedRemoteLanguages in TMGMT Translator Smartling 8
Same name and namespace in other branches
- 8.4 src/Plugin/tmgmt/Translator/SmartlingTranslator.php \Drupal\tmgmt_smartling\Plugin\tmgmt\Translator\SmartlingTranslator::getSupportedRemoteLanguages()
- 8.2 src/Plugin/tmgmt/Translator/SmartlingTranslator.php \Drupal\tmgmt_smartling\Plugin\tmgmt\Translator\SmartlingTranslator::getSupportedRemoteLanguages()
- 8.3 src/Plugin/tmgmt/Translator/SmartlingTranslator.php \Drupal\tmgmt_smartling\Plugin\tmgmt\Translator\SmartlingTranslator::getSupportedRemoteLanguages()
Gets all supported languages of the translator.
This list of all language codes used by the remote translator is then used for example in the translator settings form to select which remote language code correspond to which local language code.
Parameters
TranslatorInterface $translator: Translator entity for which to get supported languages.
Return value
array An array of language codes which are provided by the translator (remote language codes).
Overrides TranslatorPluginBase::getSupportedRemoteLanguages
1 call to SmartlingTranslator::getSupportedRemoteLanguages()
- SmartlingTranslator::getSupportedTargetLanguages in src/
Plugin/ tmgmt/ Translator/ SmartlingTranslator.php - Returns all available target languages that are supported by this service when given a source language.
File
- src/
Plugin/ tmgmt/ Translator/ SmartlingTranslator.php, line 178 - Contains \Drupal\tmgmt_smartling\Plugin\tmgmt\Translator\SmartlingTranslator.
Class
- SmartlingTranslator
- Smartling translator plugin.
Namespace
Drupal\tmgmt_smartling\Plugin\tmgmt\TranslatorCode
public function getSupportedRemoteLanguages(TranslatorInterface $translator) {
$languages = [];
// Prevent access if the translator isn't configured yet.
if (!$translator
->getSetting('project_id')) {
// @todo should be implemented by an Exception.
return $languages;
}
try {
$smartling_languages = $this
->getSmartlingApi($translator)
->getLocaleList();
foreach ($smartling_languages['locales'] as $language) {
$languages[$language['locale']] = $language['locale'];
}
} catch (\Exception $e) {
drupal_set_message($e
->getMessage(), 'Cannot get languages from the translator');
watchdog_exception('tmgmt_smartling', $e);
return $languages;
}
return $languages;
}