/**
  * Front-end form rendering.
  * @global object $sitepress
  *
  * @param array   $form
  * @param string  $ajax
  *
  * @return array
  */
 function gform_pre_render($form, $ajax)
 {
     global $sitepress;
     $st_context = $this->get_st_context($form['id']);
     // Cache
     $current_lang = $sitepress->get_current_language();
     if (isset($this->_current_forms[$form['id']][$current_lang])) {
         return $this->_current_forms[$form['id']][$current_lang];
     }
     $snh = new GFML_String_Name_Helper();
     $form = $this->populate_translated_values($form, $st_context);
     $this->get_global_strings($form, $st_context);
     // Pagination
     if (!empty($form['pagination'])) {
         // Paging Page Names - $form["pagination"]["pages"][i]
         if (isset($form['pagination']['pages']) && is_array($form['pagination']['pages'])) {
             foreach ($form['pagination']['pages'] as $page_index => $page_title) {
                 $snh->page_index = $page_index;
                 $form['pagination']['pages'][$page_index] = icl_t($st_context, $snh->get_form_pagination_page_title(), $page_title);
             }
         }
         // Completion text
         if (!empty($form['pagination']['progressbar_completion_text'])) {
             $form['pagination']['progressbar_completion_text'] = icl_t($st_context, $snh->get_form_pagination_completion_text(), $form['pagination']['progressbar_completion_text']);
         }
         // Last page button text
         // TODO not registered at my tests
         if (!empty($form['lastPageButton']['text'])) {
             $form['lastPageButton']['text'] = icl_t($st_context, $snh->get_form_pagination_last_page_button_text(), $form['lastPageButton']['text']);
         }
     }
     // Common field properties
     $keys = $this->_get_field_keys();
     // Filter form fields (array of GF_Field objects)
     foreach ($form['fields'] as $id => &$field) {
         $snh->field = $field;
         // Filter common properties
         foreach ($keys as $field_key) {
             $snh->field_key = $field_key;
             if (!empty($field->{$field_key}) && $field->type != 'page') {
                 $field->{$field_key} = icl_t($st_context, $snh->get_field_common(), $field->{$field_key});
             }
         }
         // Field specific code
         switch ($field->type) {
             case 'html':
                 $field->content = icl_t($st_context, $snh->get_field_html(), $field->content);
                 break;
             case 'page':
                 foreach (array('text', 'imageUrl') as $page_index) {
                     $snh->page_index = $page_index;
                     if (!empty($field->nextButton[$page_index])) {
                         $field->nextButton[$page_index] = icl_t($st_context, $snh->get_field_page_nextButton(), $field->nextButton[$page_index]);
                     }
                     if (isset($field->previousButton[$page_index])) {
                         $field->previousButton[$page_index] = icl_t($st_context, $snh->get_field_page_previousButton(), $field->previousButton[$page_index]);
                     }
                 }
                 break;
             case 'option':
                 // Price fields can be single or multi-option field type
                 if (in_array($field->inputType, array('singleproduct', 'singleshipping')) && $field->basePrice != '') {
                     $field->basePrice = icl_t($st_context, $snh->get_field_option_basePrice(), $field->basePrice);
                 } else {
                     if (in_array($field->inputType, array('select', 'checkbox', 'radio', 'hiddenproduct')) && is_array($field->choices)) {
                         $field = $this->handle_multi_input($field, $st_context);
                     }
                 }
                 break;
             case 'select':
             case 'multiselect':
             case 'checkbox':
             case 'list':
             case 'radio':
                 $field = $this->handle_multi_input($field, $st_context);
                 break;
             case 'post_custom_field':
                 // TODO if multi options - 'choices' (register and translate) 'inputType' => select, etc.
                 if ($field->customFieldTemplate != '') {
                     $field->customFieldTemplate = icl_t($st_context, $snh->get_field_post_custom_field(), $field->customFieldTemplate);
                 }
                 break;
             case 'post_category':
                 // TODO if multi options - 'choices' have static values (register and translate) 'inputType' => select, etc.
                 if ($field->categoryInitialItem != '') {
                     $field->categoryInitialItem = icl_t($st_context, $snh->get_field_post_category(), $field->categoryInitialItem);
                 }
                 break;
         }
         $field = $this->maybe_translate_placeholder($field, $st_context, $form);
         $field = $this->maybe_translate_customLabels($field, $st_context, $form);
     }
     $this->_current_forms[$form['id']][$current_lang] = $form;
     return $form;
 }