function locale_translation_build_server_pattern

Same name in other branches
  1. 9 core/modules/locale/locale.translation.inc \locale_translation_build_server_pattern()
  2. 8.9.x core/modules/locale/locale.translation.inc \locale_translation_build_server_pattern()
  3. 10 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

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.