function _webform_lingotek_decode_tokens in Webform 8.5
Decode all tokens after string have been translated.
Parameters
array $data: An array of data.
2 calls to _webform_lingotek_decode_tokens()
File
- includes/
webform.translation.inc, line 425 - Webform module translation hooks.
Code
function _webform_lingotek_decode_tokens(array &$data) {
$yaml = Yaml::encode($data);
$yaml = preg_replace_callback('/\\[([^]]+?)\\]/', function ($matches) {
// Decode token HTML entities to characters.
// @see https://stackoverflow.com/questions/6720826/php-convert-all-characters-to-html-entities.
$token = mb_decode_numericentity($matches[1], [
0x0,
0x10ffff,
0,
0xffffff,
], 'UTF-8');
return "[{$token}]";
}, $yaml);
$data = Yaml::decode($yaml);
}