Skip to content

Commit a53a2f3

Browse files
committed
Fixed translation text issues with special characters #142
1 parent 8f6a49c commit a53a2f3

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

system/vtpl/vtpl.php

+27-1
Original file line numberDiff line numberDiff line change
@@ -1983,7 +1983,33 @@ function ($matches) {
19831983
$f = $this->document->createElement('_script');
19841984
$f->setAttribute('language', 'php');
19851985
$f->appendChild($c);
1986-
$node = $node->parentNode->replaceChild($f, $node);
1986+
$node->parentNode->replaceChild($f, $node);
1987+
1988+
//add previously trimmed space around text
1989+
$space = str_replace($trimmed, '|', $text);
1990+
$explode = explode('|', $space);
1991+
//space before text
1992+
if ($explode[0]) {
1993+
$s = $this->document->createTextNode($explode[0]);
1994+
$f->parentNode->insertBefore($s, $f);
1995+
}
1996+
//space after text
1997+
if (isset($explode[1]) && $explode[1]) {
1998+
$e = $this->document->createTextNode($explode[1]);
1999+
//php 8
2000+
if (isset($f->nextElementSibling) && $f->nextElementSibling) {
2001+
//add before next element
2002+
$f->parentNode->insertBefore($e, $f->nextSibling);
2003+
} else {
2004+
if ($f->nextSibling) {
2005+
//add before next element
2006+
$f->parentNode->insertBefore($e, $f->nextSibling);
2007+
} else {
2008+
//add as last element
2009+
$f->parentNode->appendChild($e);
2010+
}
2011+
}
2012+
}
19872013
}
19882014
//$node->parentNode->replaceChild($f, $node);
19892015
} else {

0 commit comments

Comments
 (0)