Option MAIN_REPLACE_TRANS_xx_XX is now completely implemented.

This commit is contained in:
Laurent Destailleur 2015-10-19 13:23:45 +02:00
parent dcf7d344cd
commit 18725b554b

View File

@ -581,9 +581,8 @@ class Translate
// Make some string replacement after translation // Make some string replacement after translation
$replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang; $replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang;
if (! empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1,string2:newstring2 if (! empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2
{ {
// Overwrite translation with param MAIN_OVERWRITE_TRANS_xx_XX
$tmparray=explode(';', $conf->global->$replacekey); $tmparray=explode(';', $conf->global->$replacekey);
foreach($tmparray as $tmp) foreach($tmparray as $tmp)
{ {
@ -660,15 +659,15 @@ class Translate
{ {
$str=$this->tab_translate[$key]; $str=$this->tab_translate[$key];
// Overwrite translation // Make some string replacement after translation
$overwritekey='MAIN_OVERWRITE_TRANS_'.$this->defaultlang; $replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang;
if (! empty($conf->global->$overwritekey)) // Overwrite translation with key1:newstring1,key2:newstring2 if (! empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2
{ {
$tmparray=explode(',', $conf->global->$overwritekey); $tmparray=explode(';', $conf->global->$replacekey);
foreach($tmparray as $tmp) foreach($tmparray as $tmp)
{ {
$tmparray2=explode(':',$tmp); $tmparray2=explode(':',$tmp);
if ($tmparray2[0]==$key) { $str=$tmparray2[1]; break; } $str=preg_replace('/'.preg_quote($tmparray2[0]).'/',$tmparray2[1],$str);
} }
} }
@ -982,7 +981,8 @@ class Translate
} }
/** /**
* Return an array with content of all loaded translation keys (found into this->tab_translate) * Return an array with content of all loaded translation keys (found into this->tab_translate) so
* we get a substitution array we can use for substitutions (for mail or ODT generation for example)
* *
* @return array Array of translation keys lang_key => string_translation_loaded * @return array Array of translation keys lang_key => string_translation_loaded
*/ */
@ -997,9 +997,3 @@ class Translate
return $substitutionarray; return $substitutionarray;
} }
} }
function warning_handler($errno, $errstr, $errfile, $errline, array $errcontext) {
global $str;
print 'str='.$str;
}