From 8ff41a8ded6fdd5d03a863c3a934a0285fbb6848 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Sep 2015 15:35:51 +0200 Subject: [PATCH] Enhance performance of option MAIN_OVERWRITE_TRANS_ --- ChangeLog | 7 ++++++ htdocs/core/class/translate.class.php | 30 ++++++++++++------------- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/langs/en_US/companies.lang | 1 + 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index e079038cd01..e9bd9ffe3b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,13 @@ Upgrading to any other version or any other database system is abolutely require make a Dolibarr upgrade. +***** ChangeLog for 3.9 compared to 3.8.* ***** + +WARNING: Following changes may create regression for some external modules, but were necessary to make +Dolibarr better: +- Deprecated hidden option MAIN_USE_CUSTOM_TRANSLATION has been removed. Use MAIN_OVERWRITE_TRANS_xx_YY instead. + + ***** ChangeLog for 3.8 compared to 3.7.* ***** For users: FIX: #2519 diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 5d06586fb16..e477bdeb714 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -144,7 +144,6 @@ class Translate * If data for file already loaded, do nothing. * All data in translation array are stored in UTF-8 format. * tab_loaded is completed with $domain key. - * Warning: MAIN_USE_CUSTOM_TRANSLATION is an old deprecated feature. Do not use it. It will revert * rule "we keep first entry found with we keep last entry found" so it is probably not what you want to do. * * Value for hash are: 1:Loaded from disk, 2:Not found, 3:Loaded from cache @@ -261,7 +260,7 @@ class Translate $tab=explode('=',$line,2); $key=trim($tab[0]); //print "Domain=$domain, found a string for $tab[0] with value $tab[1]
"; - if ((! empty($conf->global->MAIN_USE_CUSTOM_TRANSLATION) || empty($this->tab_translate[$key])) && isset($tab[1])) // If translation was already found, we must not continue, even if MAIN_FORCELANGDIR is set (MAIN_FORCELANGDIR is to replace lang dir, not to overwrite entries) + if (empty($this->tab_translate[$key]) && isset($tab[1])) // If translation was already found, we must not continue, even if MAIN_FORCELANGDIR is set (MAIN_FORCELANGDIR is to replace lang dir, not to overwrite entries) { $value=trim(preg_replace('/\\n/',"\n",$tab[1])); @@ -297,7 +296,7 @@ class Translate } } - if (empty($conf->global->MAIN_FORCELANGDIR) && empty($conf->global->MAIN_USE_CUSTOM_TRANSLATION)) break; // Break loop on each root dir. If a module has forced dir, we do not stop loop. + if (empty($conf->global->MAIN_FORCELANGDIR)) break; // Break loop on each root dir. If a module has forced dir, we do not stop loop. } } } @@ -330,6 +329,19 @@ class Translate if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain]=2; // Marque ce fichier comme non trouve } + + // Overwrite translation + $overwritekey='MAIN_OVERWRITE_TRANS_'.$this->defaultlang; + if (! empty($conf->global->$overwritekey)) // Overwrite translation with key1:newstring1,key2:newstring2 + { + $tmparray=explode(',', $conf->global->$overwritekey); + foreach($tmparray as $tmp) + { + $tmparray2=explode(':',$tmp); + if (! empty($tmparray2[1])) $this->tab_translate[$tmparray2[0]]=$tmparray2[1]; + } + } + // Check to be sure that SeparatorDecimal differs from SeparatorThousand if (! empty($this->tab_translate["SeparatorDecimal"]) && ! empty($this->tab_translate["SeparatorThousand"]) && $this->tab_translate["SeparatorDecimal"] == $this->tab_translate["SeparatorThousand"]) $this->tab_translate["SeparatorThousand"]=''; @@ -410,18 +422,6 @@ class Translate { $str=$this->tab_translate[$key]; - // Overwrite translation (TODO Move this at a higher level when we load tab_translate to avoid doing it for each trans call) - $overwritekey='MAIN_OVERWRITE_TRANS_'.$this->defaultlang; - if (! empty($conf->global->$overwritekey)) // Overwrite translation with key1:newstring1,key2:newstring2 - { - $tmparray=explode(',', $conf->global->$overwritekey); - foreach($tmparray as $tmp) - { - $tmparray2=explode(':',$tmp); - if ($tmparray2[0]==$key) { $str=$tmparray2[1]; break; } - } - } - if (! preg_match('/^Format/',$key)) { //print $str; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 2a3f43e32cc..3dda4f6df7a 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -629,7 +629,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $newmenu->add("/contact/list.php?leftmenu=contacts&type=p", $langs->trans("Prospects"), 2, $user->rights->societe->contact->lire); if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $newmenu->add("/contact/list.php?leftmenu=contacts&type=c", $langs->trans("Customers"), 2, $user->rights->societe->contact->lire); if (! empty($conf->fournisseur->enabled)) $newmenu->add("/contact/list.php?leftmenu=contacts&type=f", $langs->trans("Suppliers"), 2, $user->rights->societe->contact->lire); - $newmenu->add("/contact/list.php?leftmenu=contacts&type=o", $langs->trans("Others"), 2, $user->rights->societe->contact->lire); + $newmenu->add("/contact/list.php?leftmenu=contacts&type=o", $langs->trans("ContactOthers"), 2, $user->rights->societe->contact->lire); //$newmenu->add("/contact/list.php?userid=$user->id", $langs->trans("MyContacts"), 1, $user->rights->societe->contact->lire); // Categories diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index df44a12ee44..3701925a1f4 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -338,6 +338,7 @@ ProspectLevel=Prospect potential ContactPrivate=Private ContactPublic=Shared ContactVisibility=Visibility +ContactOthers=Other OthersNotLinkedToThirdParty=Others, not linked to a third party ProspectStatus=Prospect status PL_NONE=None