l10n_update.api.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * @file
  4. * API documentation for Localize updater module.
  5. */
  6. /**
  7. * Returns available translation servers and server definitions.
  8. *
  9. * @return keyed array of available servers.
  10. * Example: array('localize.drupal.org' => array(
  11. * 'name' => 'localize.drupal.org',
  12. * 'server_url' => 'http://ftp.drupal.org/files/translations/l10n_server.xml',
  13. * 'update_url' => 'http://ftp.drupal.org/files/translations/%core/%project/%project-%release.%language.po',
  14. * ),
  15. * );
  16. */
  17. function hook_l10n_servers() {
  18. // This hook is used to specify the default localization server(s).
  19. // Additionally server data can be specified on a per project basis in the
  20. // .info file or using the hook_l10n_update_projects_alter().
  21. module_load_include('inc', 'l10n_update');
  22. $server = l10n_update_default_server();
  23. return array($server['name'] => $server );
  24. }
  25. /**
  26. * Alter the list of project to be updated by l10n update.
  27. *
  28. * l10n_update uses the same list of projects as update module. Using this hook
  29. * the list can be altered.
  30. *
  31. * @param array $projects
  32. * Array of projects.
  33. */
  34. function hook_l10n_update_projects_alter(&$projects) {
  35. // The $projects array contains the project data produced by
  36. // update_get_projects(). A number of the array elements are described in
  37. // the documentation of hook_update_projects_alter().
  38. // In the .info file of a project a localization server can be specified.
  39. // Using this hook the localization server specification can be altered or
  40. // added. The 'l10n path' element is optional but can be specified to override
  41. // the translation download path specified in the 10n_server.xml file.
  42. $projects['existing_example_project'] = array(
  43. 'info' => array(
  44. 'l10n server' => 'example.com',
  45. 'l10n url' => 'http://example.com/files/translations/l10n_server.xml',
  46. 'l10n path' => 'http://example.com/files/translations/%core/%project/%project-%release.%language.po',
  47. ),
  48. );
  49. // With this hook it is also possible to add a new project wich does not
  50. // exist as a real module or theme project but is treated by the localization
  51. // update module as one. The below data is the minumum to be specified.
  52. // As in the previous example the 'l10n path' element is optional.
  53. $projects['new_example_project'] = array(
  54. 'project_type' => 'module',
  55. 'name' => 'new_example_project',
  56. 'info' => array(
  57. 'version' => '6.x-1.5',
  58. 'core' => '6.x',
  59. 'l10n server' => 'example.com',
  60. 'l10n url' => 'http://example.com/files/translations/l10n_server.xml',
  61. 'l10n path' => 'http://example.com/files/translations/%core/%project/%project-%release.%language.po',
  62. ),
  63. );
  64. }