code: protected function translateLegend($legend, $metaModel)
      {
          $arrLegend = StringUtil::deserialize($legend['legendtitle']);
          if (is_array($arrLegend)) {
              // Try to use the language string from the array.
              $strLegend = $arrLegend[$GLOBALS['TL_LANGUAGE']];
              if (!$strLegend) {
                  // Use the fallback.
                  $strLegend = $arrLegend[$metaModel->getFallbackLanguage()];
                  if (!$strLegend) {
                      // Last resort, simply "legend". See issue #926.
                      $strLegend = 'legend' . (count($this->legends) + 1);
                  }
              }
          } else {
              $strLegend = $legend['legendtitle'] ? $legend['legendtitle'] : 'legend';
          }
  
          $legendName = StringUtil::standardize($strLegend);
  
          $this->legends[$legendName] = array
          (
              'name'       => $strLegend,
              'visible'    => !(isset($legend['legendhide']) && (bool) $legend['legendhide']),
              'properties' => array()
          );
  
          return $legendName;
      }
docs: Transform a legend information into the property legends.
  
  @param array      $legend    The legend to transform.
  
  @param IMetaModel $metaModel The metamodel the legend belongs to.
  
  @return string
  
  @SuppressWarnings(PHPMD.Superglobals)
  @SuppressWarnings(PHPMD.CamelCaseVariableName)