You are here

function range_translate_field_instance in Range 7

Translates given range field instance.

This function translates the following field instance properties:

  • field label (by i18n_field module)
  • field description (by i18n_field module)
  • FROM value form element label
  • FROM value prefix and suffix
  • TO value form element label
  • TO value prefix and suffix
  • FIELD value prefix and suffix
  • COMBINED value prefix and suffix

Parameters

array $instance: Field instance.

Return value

array Translated field instance.

3 calls to range_translate_field_instance()
range_field_formatter_view in ./range.module
Implements hook_field_formatter_view().
range_field_validate in ./range.module
Implements hook_field_validate().
range_field_widget_form in ./range.module
Implements hook_field_widget_form().

File

./range.i18n.inc, line 45
Integration with Internationalization module.

Code

function range_translate_field_instance(array $instance) {
  if (module_exists('i18n_field')) {
    foreach (_range_translatable_field_instance_settings() as $key => $title) {
      list($l1, $l2) = explode('_', $key);
      $instance['settings'][$l1][$l2] = i18n_string_translate("field:{$instance['field_name']}:{$instance['bundle']}:{$key}", $instance['settings'][$l1][$l2]);
    }
    $instance['label'] = i18n_string_translate("field:{$instance['field_name']}:{$instance['bundle']}:label", $instance['label']);
    $instance['description'] = i18n_string_translate("field:{$instance['field_name']}:{$instance['bundle']}:description", $instance['description']);
    return $instance;
  }
  else {
    return $instance;
  }
}