From 53ac124a1513434940514b6f3eda751eed6c4d3c Mon Sep 17 00:00:00 2001 From: Uma <uma.s@vtiger.com> Date: Tue, 21 Apr 2020 10:54:58 +0530 Subject: [PATCH] Fixes #1269 vtranslate arguments parsing is buggy --- includes/runtime/LanguageHandler.php | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/includes/runtime/LanguageHandler.php b/includes/runtime/LanguageHandler.php index e2a993f87..4a5a9834b 100644 --- a/includes/runtime/LanguageHandler.php +++ b/includes/runtime/LanguageHandler.php @@ -233,11 +233,30 @@ class Vtiger_Language_Handler { } function vtranslate($key, $moduleName = '') { - $args = func_get_args(); + $unformattedArgs = func_get_args(); + if(count($unformattedArgs) > 2){ + // slice an array by taking first 2 values into another array. + $formattedArgs = array_slice($unformattedArgs,0,2); + // Make third value as empty + $formattedArgs['2'] = ''; + $sliced_part = array_slice($unformattedArgs,2); + foreach ($sliced_part as $key => $value) { + array_push($formattedArgs,$value); + } + $args = $formattedArgs; + } else { + $args = $unformattedArgs; + } $formattedString = call_user_func_array(array('Vtiger_Language_Handler', 'getTranslatedString'), $args); - array_shift($args); - array_shift($args); - if (is_array($args) && !empty($args)) { + + if(count($unformattedArgs) > 2){ + // Remove first three values from an array (key,modulename,languagecode) + array_shift($args); array_shift($args);array_shift($args); + } else { + // Remove first two values from an array (key,modulename) + array_shift($args); array_shift($args); + } + if(is_array($args) && !empty($args)) { $formattedString = call_user_func_array('vsprintf', array($formattedString, $args)); } return $formattedString; -- GitLab