You are here

function _webform_localization_csv_header_select in Webform Localization 7.4

Implements _webform_localization_csv_header_component().

File

components/select.inc, line 38
Webform localizations for select component.

Code

function _webform_localization_csv_header_select($header, $component) {
  if (!isset($component['extra']['translated_strings']) || !is_array($component['extra']['translated_strings'])) {
    return $header;
  }

  // Each component has own methods and tricks to add different items to header
  // rows. Attempt to translate whatever we can.
  foreach ($component['extra']['translated_strings'] as $name) {
    $name_list = explode(':', $name);

    // Translate header from #title property, this is rather common scenario.
    if ($name_list[3] == '#title' && $component['name'] == $header[2][0]) {
      $header[2] = i18n_string($name, $component['name']);
      break;
    }

    // Title could be found from position [1][0] and in this case the select
    // options are on row 2.
    if ($name_list[3] == '#title' && $component['name'] == $header[1][0]) {
      $header[1] = i18n_string($name, $component['name']);
      foreach ($header[2] as $i => $option) {
        $header[2][$i] = webform_localization_translate_select_option($component, $option);
      }
      break;
    }
  }
  return $header;
}