function hook_lingotek_config_entity_translation_presave in Lingotek Translation 3.4.x
Same name and namespace in other branches
- 8 lingotek.api.php \hook_lingotek_config_entity_translation_presave()
- 8.2 lingotek.api.php \hook_lingotek_config_entity_translation_presave()
- 4.0.x lingotek.api.php \hook_lingotek_config_entity_translation_presave()
- 3.0.x lingotek.api.php \hook_lingotek_config_entity_translation_presave()
- 3.1.x lingotek.api.php \hook_lingotek_config_entity_translation_presave()
- 3.2.x lingotek.api.php \hook_lingotek_config_entity_translation_presave()
- 3.3.x lingotek.api.php \hook_lingotek_config_entity_translation_presave()
- 3.5.x lingotek.api.php \hook_lingotek_config_entity_translation_presave()
- 3.6.x lingotek.api.php \hook_lingotek_config_entity_translation_presave()
- 3.7.x lingotek.api.php \hook_lingotek_config_entity_translation_presave()
- 3.8.x lingotek.api.php \hook_lingotek_config_entity_translation_presave()
Act on a translation of a config entity before it is saved or updated after being downloaded from Lingotek.
Parameters
\Drupal\Core\Config\Entity\ConfigEntityInterface &$translation: The config entity that is going to be saved.
string $langcode: Drupal language code that has been downloaded.
array &$data: Data returned from the Lingotek service when asking for the translation.
Related topics
1 function implements hook_lingotek_config_entity_translation_presave()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- lingotek_test_lingotek_config_entity_translation_presave in tests/
modules/ lingotek_test/ lingotek_test.module - Implements hook_lingotek_content_entity_translation_presave().
1 invocation of hook_lingotek_config_entity_translation_presave()
File
- ./
lingotek.api.php, line 112 - Hooks provided by the Lingotek module.
Code
function hook_lingotek_config_entity_translation_presave(ConfigEntityInterface &$translation, $langcode, &$data) {
// In this example, all tokens are being decoded for block config entities.
switch ($translation
->getEntityTypeId()) {
case 'block':
// Decode all [tokens].
$yaml = Yaml::encode($data);
$yaml = preg_replace_callback('/\\[\\*\\*\\*([^]]+)\\*\\*\\*\\]/', function ($matches) {
return '[' . base64_decode($matches[1]) . ']';
}, $yaml);
$data = Yaml::decode($yaml);
break;
}
}