Error message

  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/

Remote languages mapping

Logic to deal with different language codes at client and server that stand for the same language.

For those plugins where such feature has no use there is a plugin setting "map_remote_languages" which can be set to FALSE.

Mappings info

There are several methods defined by TranslatorInterface and implemented in Translator that deal with mappings info.

  • getRemoteLanguagesMappings() - provides pairs of local_code => remote_code.
  • mapToRemoteLanguage() - helpers to map local/remote.

The above methods should not need reimplementation unless special logic is needed. However following methods provide only the fallback behaviour and therefore it is recommended that each plugin provides its specific implementation.

  • getDefaultRemoteLanguagesMappings() - we might know some mapping pairs prior to configuring a plugin, this is the place where we can define these mappings. The default implementation returns an empty array.
  • getSupportedRemoteLanguages() - gets array of language codes in

lang_code => lang_code format. It says with what languages the remote system can deal with. These codes are in the remote format.

Mapping remote to local

Mapping remote to local language codes is done when determining the language capabilities of the remote system. All following logic should then solely work with local language codes. There are two methods defined by the TranslatorInterface interface. To do the mapping a plugin must implement getSupportedTargetLanguages() defined in the TranslatorPluginInterface.

  • getSupportedTargetLanguages() - should return the remote language codes. So this method provides the remote language codes to the translator.
  • getSupportedLanguagePairs() - gets language pairs for which translations can be done. The language codes must be in remote form. The default implementation uses getSupportedTargetLanguages() so mapping occur.

Mapping local to remote

Mapping of local to remote language codes is done upon translation job request in the TranslatorPluginControllerInterface::requestTranslation() plugin implementation.


./tmgmt.api.php, line 162
Hooks provided by the Translation Management module.


Namesort descending Location Description
JobInterface::getRemoteSourceLanguage src/JobInterface.php Returns remote source language code.
JobInterface::getRemoteTargetLanguage src/JobInterface.php Returns remote target language code.
TranslatorInterface::getRemoteLanguagesMappings src/TranslatorInterface.php Gets existing remote languages mappings.
TranslatorInterface::mapToLocalLanguages src/TranslatorInterface.php Maps remote languages to local languages.
TranslatorInterface::mapToRemoteLanguage src/TranslatorInterface.php Maps local language to remote language.
TranslatorPluginInterface::getDefaultRemoteLanguagesMappings src/TranslatorPluginInterface.php Specifies default mappings for local to remote language codes.
TranslatorPluginInterface::getSupportedLanguagePairs src/TranslatorPluginInterface.php Returns supported language pairs.
TranslatorPluginInterface::getSupportedRemoteLanguages src/TranslatorPluginInterface.php Gets all supported languages of the translator.
TranslatorPluginInterface::getSupportedTargetLanguages src/TranslatorPluginInterface.php Returns all available target languages that are supported by this service when given a source language.
TranslatorPluginInterface::requestTranslation src/TranslatorPluginInterface.php @abstract