Fix: Can handle translation keys containing \"

This commit is contained in:
Laurent Destailleur 2009-05-22 22:18:59 +00:00
parent ed49d8e388
commit 2e48d482aa

View File

@ -352,10 +352,10 @@ class Translate {
*/ */
function trans($key, $param1='', $param2='', $param3='', $param4='', $maxsize=0) function trans($key, $param1='', $param2='', $param3='', $param4='', $maxsize=0)
{ {
if ($this->getTransFromTab($key)) if ($this->getTransFromTab($key)) // Translation is available
{ {
// Translation is available $str=eregi_replace('\\\"','"',$this->tab_translate[$key]); // To solve some translation keys containing key=abc\"def\"ghi instead of abc"def"ghi
$str=sprintf($this->tab_translate[$key],$param1,$param2,$param3,$param4); $str=sprintf($str,$param1,$param2,$param3,$param4);
if ($maxsize) $str=dol_trunc($str,$maxsize); if ($maxsize) $str=dol_trunc($str,$maxsize);
// On remplace les tags HTML par __xx__ pour eviter traduction par htmlentities // On remplace les tags HTML par __xx__ pour eviter traduction par htmlentities
$newstr=ereg_replace('<','__lt__',$str); $newstr=ereg_replace('<','__lt__',$str);
@ -374,9 +374,8 @@ class Translate {
$newstr=ereg_replace('__quot__','"',$newstr); $newstr=ereg_replace('__quot__','"',$newstr);
return $newstr; return $newstr;
} }
else else // Translation is not available
{ {
// Translation is not available
$newstr=$key; $newstr=$key;
if (eregi('CurrencyShort([A-Z]+)$',$key,$reg)) if (eregi('CurrencyShort([A-Z]+)$',$key,$reg))
{ {