You are here

function hook_locale_translation_projects_alter in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/locale/locale.api.php \hook_locale_translation_projects_alter()

Alter the list of projects to be updated by locale's interface translation.

Locale module attempts to update the translation of those modules returned by \Drupal\update\UpdateManager::getProjects(). Using this hook, the data returned by \Drupal\update\UpdateManager::getProjects() can be altered or extended.

Modules or distributions that use a dedicated translation server should use this hook to specify the interface translation server pattern, or to add additional custom/non-Drupal.org modules to the list of modules known to locale.

  • "interface translation server pattern": URL of the .po translation files used to download the files from. The URL contains tokens which will be replaced by appropriate values.

The following tokens are available for the server pattern:

  • "%core": Core version. Value example: "8.x".
  • "%project": Project name. Value examples: "drupal", "media_gallery".
  • "%version": Project version release. Value examples: "8.1", "8.x-1.0".
  • "%language": Language code. Value examples: "fr", "pt-pt".

Parameters

array $projects: Project data as returned by \Drupal\update\UpdateManager::getProjects().

See also

locale_translation_project_list()

Related topics

2 functions implement hook_locale_translation_projects_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

locale_test_development_release_locale_translation_projects_alter in core/modules/locale/tests/modules/locale_test_development_release/locale_test_development_release.module
Implements hook_locale_translation_projects_alter().
locale_test_locale_translation_projects_alter in core/modules/locale/tests/modules/locale_test/locale_test.module
Implements hook_locale_translation_projects_alter().
1 invocation of hook_locale_translation_projects_alter()
locale_translation_project_list in core/modules/locale/locale.compare.inc
Fetch an array of projects for translation update.

File

core/modules/locale/locale.api.php, line 117
Hooks provided by the Locale module.

Code

function hook_locale_translation_projects_alter(&$projects) {

  // The translations are located at a custom translation sever.
  $projects['existing_project'] = [
    'info' => [
      'interface translation server pattern' => 'http://example.com/files/translations/%core/%project/%project-%version.%language.po',
    ],
  ];
}