Problem/Motivation
In version 1.4.34 long HTML text fields do not contain their text value after the translation. Debugging shows, that in the functions translateHtmlWithAdvancedMethod and translateHtmlWithSimpleMethod the condition
elseif (isset($match[2])) { can never be reached. The whole condition is:
if (isset($match[1])) {
// HTML tag - keep as is
$result .= $match[1];
} elseif (isset($match[2])) {
// Text content - replace with translation if available
if (isset($segment_mapping[$index])) {
$segment_idx = $segment_mapping[$index];
$segment = $segments[$segment_idx];
$translated = $translated_segments[$segment_idx];
.......
The required logic is to check if $match[1] is empty, not if it exists. If $match[2] is set, then $match[1] always exists too. Therefore the code in the elseif condition which appends the text to the result is never executed.
Proposed resolution
Replace isset($match[1]) with !empty($match[1])
I am attaching a corresponding patch.
Comments
Comment #2
bigbabertHi @martin mayer,
this is alredy fixed in 1.5.0 (could you confirm?) that is new stable release candidate, so 1.4.x will be dismissed.
Best regards
Comment #3
martin mayer commentedI tested auto_translation 1.5 beta. It did not translate the HTML text. The text remained in the original language. So I had to revert to 1.4.34 and apply the patch to it. In that version it works again.
Comment #5
bigbabertHi @martin mayer,
thanks to review, added the fix to both versions 1.4.x and 1.5.x.
Thanks for the contribution.
Best regards
Comment #6
bigbabert