You are here

function i18nprofile_form_translate_field in Internationalization 6

Translate form field.

2 calls to i18nprofile_form_translate_field()
i18nprofile_form_translate_category in i18nprofile/i18nprofile.module
Translate form fields for a given category.
i18nprofile_profile_alter in i18nprofile/i18nprofile.module
Implementation of hook_profile_alter().

File

i18nprofile/i18nprofile.module, line 189
Internationalization (i18n) submodule: Profile translation.

Code

function i18nprofile_form_translate_field(&$form, $field) {
  if (!empty($form[$field]['#title'])) {
    $form[$field]['#title'] = i18nstrings("profile:field:{$field}:title", $form[$field]['#title']);
  }
  elseif (!empty($form[$field]['#value'])) {

    // Special treating for checboxes.
    $field_type = db_result(db_query("SELECT type FROM {profile_fields} WHERE name = '%s'", $field));
    if ($field_type == 'checkbox') {
      $form[$field]['#value'] = i18nstrings("profile:field:{$field}:title", $form[$field]['#value']);
    }
  }
  if (!empty($form[$field]['#description'])) {
    $form[$field]['#description'] = i18nstrings("profile:field:{$field}:explanation", $form[$field]['#description']);
  }
  if (!empty($form[$field]['#options'])) {
    if ($options = i18nprofile_field_options($field, $form[$field]['#options'])) {
      $form[$field]['#options'] = $options;
    }
  }
}