i18n_field.api.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * @file
  4. * API documentation file for Field translation module.
  5. *
  6. * This module takes care of translating common field elements like title and
  7. * description for all fields, plus some field specific values (default, options)
  8. * for field types defined by Drupal core.
  9. *
  10. * Before implementing any of these hooks, consider whether you would be better
  11. * off implementing Drupal core's hook_field_widget_form_alter().
  12. *
  13. * @see i18n_field_field_widget_form_alter()
  14. */
  15. /**
  16. * Provide information about callbacks for translating specific field types.
  17. *
  18. * This information can be retrieved using i18n_field_type_info().
  19. * @return
  20. * Array of values indexed by field type. Valid keys are:
  21. * - 'translate_default', Callback for translating the default value for this field type.
  22. * - 'translate_options', Callback for translating options for this field type.
  23. *
  24. * @see i18n_field_type_info()
  25. * @see i18n_field_i18n_field_info()
  26. *
  27. * For examples of both callback types:
  28. *
  29. * @see i18n_field_translate_allowed_values()
  30. * @see i18n_field_translate_default()
  31. *
  32. */
  33. function hook_i18n_field_info() {
  34. $info['text'] = $info['text_long'] = $info['text_with_summary'] = array(
  35. 'translate_default' => 'i18n_field_translate_default',
  36. );
  37. $info['list_text'] = $info['list_boolean'] = $info['list_integer'] = array(
  38. 'translate_options' => 'i18n_field_translate_allowed_values',
  39. );
  40. return $info;
  41. }
  42. /**
  43. * Alter information provided by hook_i18n_field_info().
  44. *
  45. * @see i18n_field_type_info()
  46. */
  47. function hook_i18n_field_info_alter(&$info) {
  48. // Unset the default callback for text fields.
  49. unset($info['text']['translate_default']);
  50. }