In 1.4.34 HTML fields return an empty HTML structure without text after translation

Created on 29 July 2025, 4 days ago

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.

🐛 Bug report
Status

Active

Version

1.4

Component

Code

Created by

🇩🇪Germany Martin Mayer Germany and Philippines

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024