function LocaleSource::buildServerPattern

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.

1 call to LocaleSource::buildServerPattern()
LocaleSource::sourceBuild in core/modules/locale/src/LocaleSource.php
Builds abstract translation source.

File

core/modules/locale/src/LocaleSource.php, line 245

Class

LocaleSource
Provides the locale source services.

Namespace

Drupal\locale

Code

public function buildServerPattern($project, $template) : string {
  $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.