From 14a341fb8c7edb5650efca3a3f8524b1c79993ab Mon Sep 17 00:00:00 2001 From: Ronan Pozzi Date: Tue, 10 Dec 2024 21:20:53 +0100 Subject: [PATCH] Enhance regex patterns to support underscores in keys Updated regular expressions in `translate.class.php` to allow underscores in key matches for civility, sending methods, payment types, opportunity status, and order source. This improves compatibility with broader key naming conventions. --- htdocs/core/class/translate.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 4de285710c3..ec0900a8ae7 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -629,17 +629,17 @@ class Translate $newstr = $key; $reg = array(); - if (preg_match('/^Civility([0-9A-Z]+)$/i', $key, $reg)) { + if (preg_match('/^Civility([0-9A-Z_]+)$/i', $key, $reg)) { $newstr = $this->getLabelFromKey($db, $reg[1], 'c_civility', 'code', 'label'); } elseif (preg_match('/^Currency([A-Z][A-Z][A-Z])$/i', $key, $reg)) { $newstr = $this->getLabelFromKey($db, $reg[1], 'c_currencies', 'code_iso', 'label'); - } elseif (preg_match('/^SendingMethod([0-9A-Z]+)$/i', $key, $reg)) { + } elseif (preg_match('/^SendingMethod([0-9A-Z_]+)$/i', $key, $reg)) { $newstr = $this->getLabelFromKey($db, $reg[1], 'c_shipment_mode', 'code', 'libelle'); - } elseif (preg_match('/^PaymentType(?:Short)?([0-9A-Z]+)$/i', $key, $reg)) { + } elseif (preg_match('/^PaymentType(?:Short)?([0-9A-Z_]+)$/i', $key, $reg)) { $newstr = $this->getLabelFromKey($db, $reg[1], 'c_paiement', 'code', 'libelle', '', 1); - } elseif (preg_match('/^OppStatus([0-9A-Z]+)$/i', $key, $reg)) { + } elseif (preg_match('/^OppStatus([0-9A-Z_]+)$/i', $key, $reg)) { $newstr = $this->getLabelFromKey($db, $reg[1], 'c_lead_status', 'code', 'label'); - } elseif (preg_match('/^OrderSource([0-9A-Z]+)$/i', $key, $reg)) { + } elseif (preg_match('/^OrderSource([0-9A-Z_]+)$/i', $key, $reg)) { // TODO OrderSourceX must be replaced with content of table llx_c_input_reason or llx_c_input_method //$newstr=$this->getLabelFromKey($db,$reg[1],'llx_c_input_reason','code','label'); }