From 598ffaee32452fefc8149243e8e86bf04abf05f8 Mon Sep 17 00:00:00 2001 From: lLefevre Date: Thu, 24 May 2012 16:27:16 +0000 Subject: [PATCH] // Fix translations error git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15672 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/Translate.php | 32 +++++++++++++++---------------- config/smartyfront.config.inc.php | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/classes/Translate.php b/classes/Translate.php index c485c5c41..ff0871305 100644 --- a/classes/Translate.php +++ b/classes/Translate.php @@ -55,6 +55,14 @@ class TranslateCore include_once(_PS_TRANSLATIONS_DIR_.$iso.'/admin.php'); } + if (preg_match_all('#(?:%%|%(?:[0-9]+\$)?[+-]?(?:[ 0]|\'.)?-?[0-9]*(?:\.[0-9]+)?[bcdeufFosxX])#', $string, $matches) && !is_null($sprintf)) + { + if (!is_array($sprintf)) + $sprintf = array($sprintf); + + $string = vsprintf($string, $sprintf); + } + if (isset($modules_tabs[strtolower($class)])) { $class_name_controller = $class.'controller'; @@ -75,14 +83,6 @@ class TranslateCore $str = $htmlentities ? htmlentities($str, ENT_QUOTES, 'utf-8') : $str; $str = str_replace('"', '"', $str); - if (preg_match_all('#(?:%%|%(?:[0-9]+\$)?[+-]?(?:[ 0]|\'.)?-?[0-9]*(?:\.[0-9]+)?[bcdeufFosxX])#', $str, $matches) && !is_null($sprintf)) - { - if (!is_array($sprintf)) - $sprintf = array($sprintf); - - $str = vsprintf($str, $sprintf); - } - return ($addslashes ? addslashes($str) : stripslashes($str)); } @@ -174,6 +174,14 @@ class TranslateCore $cache_key = $name.'|'.$string.'|'.$source; if (!isset($lang_cache[$cache_key])) { + if (preg_match_all('#(?:%%|%(?:[0-9]+\$)?[+-]?(?:[ 0]|\'.)?-?[0-9]*(?:\.[0-9]+)?[bcdeufFosxX])#', $string, $matches) && !is_null($sprintf)) + { + if (!is_array($sprintf)) + $sprintf = array($sprintf); + + $string = vsprintf($string, $sprintf); + } + if ($_MODULES == null) return str_replace('"', '"', $string); @@ -190,14 +198,6 @@ class TranslateCore else $ret = stripslashes($string); - if (preg_match_all('#(?:%%|%(?:[0-9]+\$)?[+-]?(?:[ 0]|\'.)?-?[0-9]*(?:\.[0-9]+)?[bcdeufFosxX])#', $ret, $matches) && !is_null($sprintf)) - { - if (!is_array($sprintf)) - $sprintf = array($sprintf); - - $ret = vsprintf($ret, $sprintf); - } - $lang_cache[$cache_key] = str_replace('"', '"', $ret); } return $lang_cache[$cache_key]; diff --git a/config/smartyfront.config.inc.php b/config/smartyfront.config.inc.php index 39bc1e083..2faf094fd 100644 --- a/config/smartyfront.config.inc.php +++ b/config/smartyfront.config.inc.php @@ -34,7 +34,7 @@ function smartyTranslate($params, &$smarty) if (!isset($params['js'])) $params['js'] = 0; if (!isset($params['pdf'])) $params['pdf'] = false; if (!isset($params['mod'])) $params['mod'] = false; - if (!isset($params['sprintf'])) $params['sprintf'] = false; + if (!isset($params['sprintf'])) $params['sprintf'] = null; $string = str_replace('\'', '\\\'', $params['s']); $filename = ((!isset($smarty->compiler_object) || !is_object($smarty->compiler_object->template)) ? $smarty->template_resource : $smarty->compiler_object->template->getTemplateFilepath()); @@ -61,7 +61,7 @@ function smartyTranslate($params, &$smarty) if ($msg != $params['s']) $msg = $params['js'] ? addslashes($msg) : stripslashes($msg); - if ($params['sprintf']) + if (preg_match_all('#(?:%%|%(?:[0-9]+\$)?[+-]?(?:[ 0]|\'.)?-?[0-9]*(?:\.[0-9]+)?[bcdeufFosxX])#', $msg, $matches) && !is_null($params['sprintf'])) { if (!is_array($params['sprintf'])) $params['sprintf'] = array($params['sprintf']);