Skip to content

Commit 0c0fcde

Browse files
author
Oleksii Korshenko
committed
MAGETWO-52789: Inline translation form is broken for special tags
- fixed unit tests
1 parent 4c19ad9 commit 0c0fcde

File tree

1 file changed

+12
-9
lines changed
  • app/code/Magento/Translation/Model/Inline

1 file changed

+12
-9
lines changed

app/code/Magento/Translation/Model/Inline/Parser.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -559,16 +559,19 @@ private function _translateTags(&$content, $tagsList, $formatCallback)
559559

560560
$tagBodyMatch = [];
561561
preg_match($tagRegExpBody, $content, $tagBodyMatch, PREG_OFFSET_CAPTURE);
562-
$tagBodyOpenStartPosition = $tagBodyMatch[0][1];
563-
564-
if (array_key_exists($tagName, $this->_allowedTagsGlobal)
565-
&& $tagBodyOpenStartPosition > $tagMatch[0][1]
566-
) {
567-
$tagHtmlHead = call_user_func([$this, $formatCallback], $tagHtml, $tagName, $trArr);
568-
$headTranslateTags .= substr($tagHtmlHead, strlen($tagHtml));
569-
} else {
570-
$tagHtml = call_user_func([$this, $formatCallback], $tagHtml, $tagName, $trArr);
562+
if (!empty($tagBodyMatch)) {
563+
$tagBodyOpenStartPosition = $tagBodyMatch[0][1];
564+
565+
if (array_key_exists($tagName, $this->_allowedTagsGlobal)
566+
&& $tagBodyOpenStartPosition > $tagMatch[0][1]
567+
) {
568+
$tagHtmlHead = call_user_func([$this, $formatCallback], $tagHtml, $tagName, $trArr);
569+
$headTranslateTags .= substr($tagHtmlHead, strlen($tagHtml));
570+
} else {
571+
$tagHtml = call_user_func([$this, $formatCallback], $tagHtml, $tagName, $trArr);
572+
}
571573
}
574+
572575
$tagClosurePos = $tagMatch[0][1] + strlen($tagHtml);
573576
$content = substr_replace($content, $tagHtml, $tagMatch[0][1], $tagLength);
574577
}

0 commit comments

Comments
 (0)