You are here

function _potx_format_quoted_string in Translation template extractor 8

Same name and namespace in other branches
  1. 5.2 potx.inc \_potx_format_quoted_string()
  2. 5 potx.inc \_potx_format_quoted_string()
  3. 6.3 potx.inc \_potx_format_quoted_string()
  4. 6 potx.inc \_potx_format_quoted_string()
  5. 6.2 potx.inc \_potx_format_quoted_string()
  6. 7.3 potx.inc \_potx_format_quoted_string()
  7. 7 potx.inc \_potx_format_quoted_string()
  8. 7.2 potx.inc \_potx_format_quoted_string()

Escape quotes in a strings.

The quotes are escaped depending on the surrounding quote type used.

Parameters

string $str: The strings to escape.

21 calls to _potx_format_quoted_string()
PotxTest::assertMsgId in tests/src/Kernel/PotxTest.php
Assert a msgid construct in the .po file.
PotxTest::assertMsgIdContext in tests/src/Kernel/PotxTest.php
Assert a msgid with context in the .po file.
PotxTest::assertNoMsgId in tests/src/Kernel/PotxTest.php
Assert the lack of a msgid construct in the .po file.
PotxTest::assertNoMsgIdContext in tests/src/Kernel/PotxTest.php
Assert the lack of a msgid with context in the .po file.
PotxTest::assertNoPluralIdContext in tests/src/Kernel/PotxTest.php
Assert the lack of msgid_plural with context in the .po file.

... See full list

File

./potx.inc, line 818
Extraction API used by the web and command line interface.

Code

function _potx_format_quoted_string($str) {
  $quo = substr($str, 0, 1);
  $str = substr($str, 1, -1);
  if ($quo == '"') {
    $str = stripcslashes($str);
  }
  else {
    $str = strtr($str, [
      "\\'" => "'",
      "\\\\" => "\\",
    ]);
  }
  return addcslashes($str, "\0..\37\\\"");
}