[-] BO : #PSCFV-2591 : fix translations in bankwire module

This commit is contained in:
lLefevre
2012-05-29 12:50:59 +00:00
parent 7f19fcc91a
commit 91aaa63f26
2 changed files with 28 additions and 22 deletions
+27 -15
View File
@@ -55,14 +55,6 @@ 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';
@@ -83,6 +75,8 @@ class TranslateCore
$str = $htmlentities ? htmlentities($str, ENT_QUOTES, 'utf-8') : $str;
$str = str_replace('"', '"', $str);
$str = Translate::checkAndReplaceArgs($str, $sprintf);
return ($addslashes ? addslashes($str) : stripslashes($str));
}
@@ -172,18 +166,15 @@ class TranslateCore
$key = md5(str_replace('\'', '\\\'', $string));
$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)
{
$string = Translate::checkAndReplaceArgs($string, $sprintf);
return str_replace('"', '"', $string);
}
$current_key = strtolower('<{'.$name.'}'._THEME_NAME_.'>'.$source).'_'.$key;
$default_key = strtolower('<{'.$name.'}prestashop>'.$source).'_'.$key;
@@ -198,6 +189,8 @@ class TranslateCore
else
$ret = stripslashes($string);
$ret = Translate::checkAndReplaceArgs($ret, $sprintf);
$lang_cache[$cache_key] = str_replace('"', '&quot;', $ret);
}
return $lang_cache[$cache_key];
@@ -235,5 +228,24 @@ class TranslateCore
return $str;
}
/**
* Check if string use a specif syntax for sprintf and replace arguments if use it
*
* @param $string
* @param $args
* @return string
*/
public static function checkAndReplaceArgs($string, $args)
{
if (preg_match_all('#(?:%%|%(?:[0-9]+\$)?[+-]?(?:[ 0]|\'.)?-?[0-9]*(?:\.[0-9]+)?[bcdeufFosxX])#', $string, $matches) && !is_null($args))
{
if (!is_array($args))
$args = array($args);
return vsprintf($string, $args);
}
return $string;
}
}
+1 -7
View File
@@ -61,13 +61,7 @@ function smartyTranslate($params, &$smarty)
if ($msg != $params['s'])
$msg = $params['js'] ? addslashes($msg) : stripslashes($msg);
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']);
$msg = vsprintf($msg, $params['sprintf']);
}
$msg = Translate::checkAndReplaceArgs($msg, $params['sprintf']);
return $params['js'] ? $msg : Tools::htmlentitiesUTF8($msg);
}