profile2_i18n.module 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * @file
  4. * Profile2 i18n integration module via entity API i18n support.
  5. *
  6. * @see EntityDefaultI18nController
  7. */
  8. /**
  9. * Implements hook_entity_info_alter().
  10. */
  11. function profile2_i18n_entity_info_alter(&$info) {
  12. // Enable i18n support via the entity API.
  13. $info['profile2_type']['i18n controller class'] = 'EntityDefaultI18nStringController';
  14. }
  15. /**
  16. * Implements hook_entity_property_info_alter().
  17. */
  18. function profile2_i18n_entity_property_info_alter(&$info) {
  19. // Mark some properties as translatable, but also denote that translation
  20. // works with i18n_string.
  21. foreach (array('label') as $name) {
  22. $info['profile2_type']['properties'][$name]['translatable'] = TRUE;
  23. $info['profile2_type']['properties'][$name]['i18n string'] = TRUE;
  24. }
  25. }
  26. /**
  27. * Implements hook_profile2_type_insert().
  28. */
  29. function profile2_i18n_profile2_type_insert($profile_type) {
  30. i18n_string_object_update('profile2_type', $profile_type);
  31. }
  32. /**
  33. * Implements hook_profile2_type_update().
  34. */
  35. function profile2_i18n_profile2_type_update($profile_type) {
  36. // Account for name changes.
  37. if ($profile_type->original->type != $profile_type->type) {
  38. i18n_string_update_context("profile2:profile2_type:{$profile_type->original->type}:*", "profile2:profile2_type:{$profile_type->type}:*");
  39. }
  40. i18n_string_object_update('profile2_type', $profile_type);
  41. }
  42. /**
  43. * Implements hook_profile2_type_delete().
  44. */
  45. function profile2_i18n_profile2_type_delete($profile_type) {
  46. i18n_string_object_remove('profile2_type', $profile_type);
  47. }