You are here

Remote languages mapping in Translation Management Tool 7

Same name and namespace in other branches
  1. 8 tmgmt.api.php \tmgmt_remote_languages_mapping

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

Each tmgmt plugin is expected to support this feature. However 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 TMGMTTranslatorPluginControllerInterface and implemented in TMGMTDefaultTranslatorPluginController that deal with mappings info.

  • getRemoteLanguagesMappings() - provides pairs of local_code => remote_code.
  • mapToRemoteLanguage() & mapToLocalLanguage() - helpers to map local/remote. Note that methods with same names and functionality are provided by the TMGMTTranslator entity. These are convenience methods.

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 TMGMTTranslatorPluginControllerInterface interface. To do the mapping a plugin must implement getSupportedTargetLanguages().

  • getSupportedTargetLanguages() - should return local language codes. So within this method the mapping needs to be executed.
  • getSupportedLanguagePairs() - gets language pairs for which translations can be done. The language codes must be in local form. The default implementation uses getSupportedTargetLanguages() so mapping occur. However this approach is not effective and therefore each plugin should provide its specific implementation with regard to performance.

Mapping local to remote

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

File

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

Functions

Namesort descending Location Description
TMGMTTranslator::mapToLocalLanguage entity/tmgmt.entity.translator.inc Maps remote language to local language.
TMGMTTranslator::mapToRemoteLanguage entity/tmgmt.entity.translator.inc Maps local language to remote language.
TMGMTTranslatorPluginControllerInterface::getDefaultRemoteLanguagesMappings plugin/tmgmt.plugin.interface.translator.inc Specifies default mappings for local to remote language codes.
TMGMTTranslatorPluginControllerInterface::getRemoteLanguagesMappings plugin/tmgmt.plugin.interface.translator.inc Gets existing remote languages mappings.
TMGMTTranslatorPluginControllerInterface::getSupportedLanguagePairs plugin/tmgmt.plugin.interface.translator.inc Returns supported language pairs.
TMGMTTranslatorPluginControllerInterface::getSupportedRemoteLanguages plugin/tmgmt.plugin.interface.translator.inc Gets all supported languages of the translator.
TMGMTTranslatorPluginControllerInterface::getSupportedTargetLanguages plugin/tmgmt.plugin.interface.translator.inc Returns all available target languages that are supported by this service when given a source language.
TMGMTTranslatorPluginControllerInterface::mapToLocalLanguage plugin/tmgmt.plugin.interface.translator.inc Maps remote language to local language.
TMGMTTranslatorPluginControllerInterface::mapToRemoteLanguage plugin/tmgmt.plugin.interface.translator.inc Maps local language to remote language.
TMGMTTranslatorPluginControllerInterface::requestTranslation plugin/tmgmt.plugin.interface.translator.inc @abstract