You are here

function i18nprofile_form_translate in Internationalization 5.2

Same name and namespace in other branches
  1. 5.3 i18nprofile/i18nprofile.module \i18nprofile_form_translate()
  2. 5 i18nprofile/i18nprofile.module \i18nprofile_form_translate()

Translate form fields for a given category

2 calls to i18nprofile_form_translate()
i18nprofile_form_alter in i18nprofile/i18nprofile.module
Implementation of hook_form_alter()
i18nprofile_form_translate_all in i18nprofile/i18nprofile.module
Translate form fields for all categories

File

i18nprofile/i18nprofile.module, line 142

Code

function i18nprofile_form_translate($form_id, &$form, $category) {

  // Translate category fieldset
  $categories = i18nprofile_categories(TRUE);
  if (isset($categories[$category])) {
    $form[$category]['#title'] = $categories[$category];
  }

  // Translate field titles and names
  $fields = i18nprofile_fields($category);
  foreach ($fields as $name => $field) {
    if (isset($form[$category][$name])) {
      if ($field->title) {
        $form[$category][$name]['#title'] = $field->title;
      }
      if ($field->explanation) {
        $form[$category][$name]['#description'] = $field->explanation;
      }
      if ($form[$category][$name]['#type'] == 'select' && ($options = unserialize($field->options))) {
        $form[$category][$name]['#options'] = $options;
      }
    }
  }
}