i18n_block.i18n.inc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * @file
  4. * Internationalization (i18n) hooks
  5. */
  6. /**
  7. * Implements hook_i18n_object_info().
  8. */
  9. function i18n_block_i18n_object_info() {
  10. $info['block'] = array(
  11. 'title' => t('Block'),
  12. 'class' => 'i18n_block_object',
  13. 'load callback' => 'block_load',
  14. 'key' => array('module', 'delta'),
  15. 'placeholders' => array(
  16. '%module' => 'module',
  17. '%delta' => 'delta',
  18. ),
  19. 'edit path' => 'admin/structure/block/manage/%module/%delta/configure',
  20. 'string translation' => array(
  21. 'textgroup' => 'blocks',
  22. 'properties' => array(
  23. 'title' => array(
  24. 'title' => t('Title'),
  25. 'empty' => '<none>',
  26. ),
  27. 'body' => array(
  28. 'title' => t('Body'),
  29. 'format' => 'format',
  30. ),
  31. ),
  32. 'translate path' => 'admin/structure/block/manage/%module/%delta/translate/%i18n_language',
  33. )
  34. );
  35. return $info;
  36. }
  37. /**
  38. * Implements hook_i18n_string_info().
  39. */
  40. function i18n_block_i18n_string_info() {
  41. $groups['blocks'] = array(
  42. 'title' => t('Blocks'),
  43. 'description' => t('Configurable blocks titles and content.'),
  44. 'format' => TRUE, // This group has strings with format (block body)
  45. 'list' => TRUE, // This group can list all strings
  46. );
  47. return $groups;
  48. }
  49. /**
  50. * Implements hook_i18n_string_objects().
  51. */
  52. function i18n_block_i18n_string_objects($type) {
  53. if ($type == 'block') {
  54. $query = db_select('block', 'b')
  55. ->distinct()
  56. ->fields('b', array('module', 'delta', 'title', 'i18n_mode'))
  57. ->fields('bc', array('body', 'format'))
  58. ->condition('i18n_mode', I18N_MODE_LOCALIZE);
  59. $query->leftJoin('block_custom', 'bc', 'b.bid = bc.bid');
  60. return $query->execute()->fetchAll(PDO::FETCH_OBJ);
  61. }
  62. }