l10n_update.api.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * @file
  4. * API documentation for Localize updater module.
  5. */
  6. /**
  7. * Alter the list of project to be updated by Localization Update.
  8. *
  9. * L10n_update uses the same list of projects as update module. Using this hook
  10. * the list can be altered. This hook is typically used to alter the following
  11. * values from the .info file:
  12. * - interface translation project
  13. * - l10n path.
  14. *
  15. * @param array $projects
  16. * Array of projects.
  17. */
  18. function hook_l10n_update_projects_alter(array &$projects) {
  19. foreach (array_keys($projects) as $name) {
  20. // @todo These 'interface translation project' examples are good for system_projects_alter.
  21. // Make all custom_* modules use the 'custom_module' module translation
  22. // file.
  23. if (strpos($name, 'custom_') === 0) {
  24. $projects[$name]['info']['interface translation project'] = 'custom_module';
  25. }
  26. // Disable interface translation updates for all features.
  27. if (strpos($name, 'feature_') === 0) {
  28. $projects[$name]['info']['interface translation project'] = FALSE;
  29. }
  30. }
  31. // Set the path to the custom module translation files if not already set.
  32. if (isset($projects['custom_module']) && empty($projects['custom_module']['info']['l10n path'])) {
  33. $path = drupal_get_path('module', 'custom_module');
  34. $projects['custom_module']['info']['l10n path'] = $path . '/translations/%language.po';
  35. }
  36. // With this hook it is also possible to add a new project which does not
  37. // exist as a real module or theme project but is treated by the localization
  38. // update module as one. The below data is the minimum to be specified.
  39. // As in the previous example the 'l10n path' element is optional.
  40. $projects['new_example_project'] = array(
  41. 'project_type' => 'module',
  42. 'name' => 'new_example_project',
  43. 'info' => array(
  44. 'name' => 'New example project',
  45. 'version' => '7.x-1.5',
  46. 'core' => '7.x',
  47. 'l10n path' => 'http://example.com/files/translations/%core/%project/%project-%release.%language.po',
  48. ),
  49. );
  50. }
  51. /**
  52. * Alter the list of languages to be updated by Localization Update.
  53. *
  54. * @param array $langcodes
  55. * Language codes of languages to be updated by Localization Update module.
  56. */
  57. function hook_l10n_update_languages_alter(array &$langcodes) {
  58. // Use a different language code for Dutch translations.
  59. if (isset($langcodes['nl'])) {
  60. $langcodes['nl-NL'] = $langcodes['nl'];
  61. unset($langcodes['nl']);
  62. }
  63. }