Skip to content

MultiPickList values aren't translated in detail view 6.4.0

When a module has a multi-picklist value and there is a language-translation file providing a translation for those values, it is "ignored" in detail (and summary) view of data. Instead, when you enter edit view, the values are correctly translated. I found that it's an issue in this file:

/modules/Vtiger/uitypes/Multipicklist.php

The function getDisplayValue() doesn't translate the values... it simply construct the string to print out. It should by fixed as follows (or something more efficient):

    public function getDisplayValue($value) {
       if(is_array($value)){
          $numElements = count($value);
          for($i=0; $i<$numElements; $i++) {
             $value[$i] = Vtiger_Language_Handler::getTranslatedString($value[$i], $this->get('field')->getModuleName());
          }
          $value = implode(' |##| ', $value);
       } else {
          $myValues = explode(' |##| ', $value);
          $numElements = count($myValues);
          for($i=0; $i<$numElements; $i++) {
             $myValues[$i] = Vtiger_Language_Handler::getTranslatedString($myValues[$i], $this->get('field')->getModuleName());
          }
          $value = implode(' |##| ', $myValues);
       }
       return str_ireplace(' |##| ', ', ', $value);
    }

For example, Picklist.php (in the same directory) take care of language translation for the value actually selected. It should be done by Multipicklist.php too.