You are here

public function TMGMTDefaultTranslatorPluginController::mapToLocalLanguage in Translation Management Tool 7

Maps remote language to local language.

Parameters

TMGMTTranslator $translator: Translator entity for which to get local language.

$language: Remote language code.

Return value

string Local language code.

Overrides TMGMTTranslatorPluginControllerInterface::mapToLocalLanguage

File

plugin/tmgmt.plugin.translator.inc, line 115
Contains the abstract translator base plugin class.

Class

TMGMTDefaultTranslatorPluginController
Default controller class for service plugins.

Code

public function mapToLocalLanguage(TMGMTTranslator $translator, $language) {
  if (!tmgmt_provide_remote_languages_mappings($translator)) {
    return $language;
  }
  if (isset($translator->settings['remote_languages_mappings']) && is_array($translator->settings['remote_languages_mappings'])) {
    $mappings = $translator->settings['remote_languages_mappings'];
  }
  else {
    $mappings = $this
      ->getDefaultRemoteLanguagesMappings();
  }
  if ($remote_language = array_search($language, $mappings)) {
    return $remote_language;
  }
  return $language;
}