You are here

function i18n_string_translate_page_form in Internationalization 7

Form builder callback for in-place string translation.

Parameters

$strings: Array of strings indexed by string name (may be indexed by group key too if $groups is present)

$langcode: Language code to translate to.

$groups: Optional groups to provide some string grouping. Array with group key and title pairs.

2 string references to 'i18n_string_translate_page_form'
i18n_field_page_translate in i18n_field/i18n_field.pages.inc
Field translation page
i18n_string_translate_page_object in i18n_string/i18n_string.pages.inc
Generate translate page from object.

File

i18n_string/i18n_string.pages.inc, line 124
Internationalization (i18n) package - translatable strings reusable admin UI.

Code

function i18n_string_translate_page_form($form, &$form_state, $strings, $langcode, $groups = NULL) {
  $form = i18n_string_translate_page_form_base($form, $langcode);
  if ($groups) {

    // I we've got groups, string list is grouped by group key.
    $form['string_groups'] = array(
      '#type' => 'value',
      '#value' => $strings,
    );
    foreach ($groups as $key => $title) {
      $form['display'] = array(
        '#type' => 'vertical_tabs',
      );
      $form['strings'][$key] = array(
        '#group' => 'display',
        '#title' => $title,
        '#type' => 'fieldset',
      ) + i18n_string_translate_page_form_strings($strings[$key], $langcode);
    }
  }
  else {

    // We add a single group with key 'all', but no tabs.
    $form['string_groups'] = array(
      '#type' => 'value',
      '#value' => array(
        'all' => $strings,
      ),
    );
    $form['strings']['all'] = i18n_string_translate_page_form_strings($strings, $langcode);
  }
  return $form;
}