From 9f0c0bfc927ac3bbf465f1061514336f7714ebb3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Oct 2015 13:27:44 +0200 Subject: [PATCH] NEW Introduce hidden option MAIN_REPLACE_TRANS_xx_XX to allow simple replacement of translated string on the fly. --- htdocs/core/class/translate.class.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 27bcb64da3c..8235f99d129 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2012 Destailleur Laurent + * Copyright (C) 2004-2015 Destailleur Laurent * Copyright (C) 2005-2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -579,6 +579,19 @@ class Translate { $str=$this->tab_translate[$key]; + // Make some string replacement after translation + $replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang; + 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); + foreach($tmparray as $tmp) + { + $tmparray2=explode(':',$tmp); + $str=preg_replace('/'.preg_quote($tmparray2[0]).'/',$tmparray2[1],$str); + } + } + if (! preg_match('/^Format/',$key)) { //print $str;