// Fix translations error
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15672 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -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];
|
||||
|
||||
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user