You are here

public function SvgEmbedProcess::translate in SVG Embed 2.0.x

Same name and namespace in other branches
  1. 8 src/SvgEmbedProcess.php \Drupal\svg_embed\SvgEmbedProcess::translate()

Parameters

string $uuid:

string $langcode:

Return value

string

Overrides SvgEmbedProcessInterface::translate

File

src/SvgEmbedProcess.php, line 51

Class

SvgEmbedProcess
Class SvgEmbedProcess.

Namespace

Drupal\svg_embed

Code

public function translate($uuid, $langcode) : string {
  $xml = $this
    ->loadFile($uuid);
  if ($this->moduleHandler
    ->moduleExists('locale')) {

    // Go through the DOM and translate all relevant strings.
    $this
      ->embedTranslate($xml, $langcode);
  }

  // Strip early comments and a potential xml tag.
  $svg = $xml
    ->asXML();
  $svg_tag = strpos($svg, '<svg');
  return substr($svg, $svg_tag);
}