i18n_sync.api.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * @file
  4. * Synchronization API documentation
  5. */
  6. /**
  7. * Provide information about which fields to synchronize for each entity type.
  8. *
  9. * @see i18n_sync_options()
  10. *
  11. * Field definitions defined on hook_field_info() may contain a synchronization
  12. * callback used for that field to be synchronized. This callback can be set by:
  13. * $field['i18n_sync_callback'] = 'sychcronize_function_callback
  14. *
  15. * This callback will be invoked with the following parameters
  16. * - $entity_type, $entity, $field, $instance, $langcode, $items, $source_entity, $source_langcode);
  17. *
  18. * @see i18n_sync_field_info_alter()
  19. * @see i18n_sync_field_file_sync()
  20. *
  21. * @return array
  22. * Array of fields indexed by field name that will be presented as options
  23. * to be synchronized. Each element is an array with the following keys:
  24. * - 'title', Field title to be displayed
  25. * - 'description', Field description to be displayed.
  26. * - 'field_name', Field name for configurable Fields.
  27. * - 'group', Group for the UI only to display this field.
  28. *
  29. */
  30. function hook_i18n_sync_options($entity_type, $bundle_name) {
  31. if ($entity_type == 'node') {
  32. return array(
  33. 'parent' => array(
  34. 'title' => t('Book outline'),
  35. 'description' => t('Set the translated parent for each translation if possible.')
  36. ),
  37. );
  38. }
  39. }
  40. /**
  41. * Alter information about synchronization options for entities/field
  42. *
  43. * @see hook_i18n_sync_options()
  44. */
  45. function hook_i18n_sync_options_alter(&$fields, $entity_type, $bundle_name) {
  46. }
  47. /**
  48. * Perform aditional synchronization on entities
  49. *
  50. * @param $entity_type
  51. * @param $translation
  52. * Translated entity.
  53. * @param $translation_language
  54. * Translated entity language code.
  55. * @param $source
  56. * Source entity.
  57. * @param $source_language
  58. * Source entity language code.
  59. * @param $field_names
  60. * Array of field names to synchronize.
  61. */
  62. function hook_i18n_sync_translation($entity_type, $translation, $translation_language, $source, $source_language, $field_names) {
  63. }