From b69c89f4b92be154ca855094ddb29db6de436ebc Mon Sep 17 00:00:00 2001 From: 202 ecommerce <202-ecommerce@users.noreply.github.com> Date: Fri, 5 Jul 2019 16:33:08 +0200 Subject: [PATCH 1/2] Fix bug of FO translations with multiple resources and tpl inclusions --- config/smartyfront.config.inc.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/smartyfront.config.inc.php b/config/smartyfront.config.inc.php index 4a2048eb18a83..ec80e7953d58b 100644 --- a/config/smartyfront.config.inc.php +++ b/config/smartyfront.config.inc.php @@ -217,7 +217,10 @@ function smartyTranslate($params, $smarty) } $string = str_replace('\'', '\\\'', $params['s']); - $basename = basename($smarty->source->name, '.tpl'); + $resourcePrefix = substr($smarty->source->resource, 0, strpos($smarty->source->resource, ':')); + $templatePrefix = substr($smarty->template_resource, 0, strpos($smarty->template_resource, ':')); + $filename = $resourcePrefix === $templatePrefix ? $smarty->source->resource : $smarty->template_resource; + $basename = basename($filename, '.tpl'); $key = $basename.'_'.md5($string); if (isset($smarty->source) && (strpos($smarty->source->filepath, DIRECTORY_SEPARATOR.'override'.DIRECTORY_SEPARATOR) !== false)) { From 1be381019813482c4d899d8734cb89878338000c Mon Sep 17 00:00:00 2001 From: 202 ecommerce <202-ecommerce@users.noreply.github.com> Date: Mon, 8 Jul 2019 11:20:13 +0200 Subject: [PATCH 2/2] fix inheritance template filename in case of includes from different cross sources between theme, modules, ... --- config/smartyfront.config.inc.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/config/smartyfront.config.inc.php b/config/smartyfront.config.inc.php index ec80e7953d58b..a789e4d80fd1e 100644 --- a/config/smartyfront.config.inc.php +++ b/config/smartyfront.config.inc.php @@ -217,9 +217,13 @@ function smartyTranslate($params, $smarty) } $string = str_replace('\'', '\\\'', $params['s']); - $resourcePrefix = substr($smarty->source->resource, 0, strpos($smarty->source->resource, ':')); - $templatePrefix = substr($smarty->template_resource, 0, strpos($smarty->template_resource, ':')); - $filename = $resourcePrefix === $templatePrefix ? $smarty->source->resource : $smarty->template_resource; + + // fix inheritance template filename in case of includes from different cross sources between theme, modules, ... + $filename = $smarty->template_resource; + if (!isset($smarty->inheritance->sourceStack[0]) || $filename === $smarty->inheritance->sourceStack[0]->resource) { + $filename = $smarty->source->name; + } + $basename = basename($filename, '.tpl'); $key = $basename.'_'.md5($string);