You are here

public static function LingotekConfigChunk::filterPlaceholders in Lingotek Translation 7.3

Wrap placeholder tags in specific tags that will be ignored by Lingotek

Parameters

$segment_text: a string containing the segment to be translated

Return value

string the original input plus any additional reference tags to be ignored.

1 call to LingotekConfigChunk::filterPlaceholders()
LingotekConfigChunk::documentLingotekXML in lib/Drupal/lingotek/LingotekConfigChunk.php
Gets the contents of this item formatted as XML to be sent to Lingotek.

File

lib/Drupal/lingotek/LingotekConfigChunk.php, line 560
Defines LingotekConfigChunk.

Class

LingotekConfigChunk
A class wrapper for Lingotek-specific behavior on ConfigChunks.

Code

public static function filterPlaceholders($segment_text) {

  // NOTE: This regex is only a generalization of the variable names possible using
  // the t-function's variable interpolation.  This finds all sets of word
  // characters (A-Z, a-z, - or _) that begin with either !, @, or %, that do not
  // fall between angle brackets (which would indicate being on the inside
  // of an HTML tag).
  $pattern = '/([!@%][\\w_-]+\\s*)(?![^<]*\\>)/';
  $replacement = '<drupalvar>${1}</drupalvar>';
  return preg_replace($pattern, $replacement, $segment_text);
}