You are here

function locale_translation_build_server_pattern in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/locale/locale.translation.inc \locale_translation_build_server_pattern()
  2. 9 core/modules/locale/locale.translation.inc \locale_translation_build_server_pattern()

Build path to translation source, out of a server path replacement pattern.

Parameters

object $project: Project object containing data to be inserted in the template.

string $template: String containing placeholders. Available placeholders:

  • "%project": Project name.
  • "%version": Project version.
  • "%core": Project core version.
  • "%language": Language code.

Return value

string String with replaced placeholders.

2 calls to locale_translation_build_server_pattern()
LocaleBuildTest::testBuildProjects in core/modules/locale/tests/src/Kernel/LocaleBuildTest.php
Checks if a list of translatable projects gets built.
locale_translation_source_build in core/modules/locale/locale.translation.inc
Builds abstract translation source.

File

core/modules/locale/locale.translation.inc, line 316
Common API for interface translation.

Code

function locale_translation_build_server_pattern($project, $template) {
  $variables = [
    '%project' => $project->name,
    '%version' => $project->version,
    '%core' => $project->core,
    '%language' => $project->langcode ?? '%language',
  ];
  return strtr($template, $variables);
}