|
static | multilineQuote ($string) |
| Escapes and adds double quotes to a string. More...
|
|
static | addLines (array &$lines, $name, $value) |
| Add one or more lines depending whether the string is multiline or not. More...
|
|
Definition at line 7 of file Po.php.
◆ addLines()
static Gettext\Generators\Po::addLines |
( |
array & |
$lines, |
|
|
|
$name, |
|
|
|
$value |
|
) |
| |
|
staticprivate |
Add one or more lines depending whether the string is multiline or not.
- Parameters
-
array | &$lines | |
string | $name | |
string | $value | |
Definition at line 101 of file Po.php.
References $name.
103 $newLines = self::multilineQuote($value);
105 if (count($newLines) === 1) {
106 $lines[] =
$name.
' '.$newLines[0];
108 $lines[] =
$name.
' ""';
110 foreach ($newLines as $line) {
◆ convertString()
static Gettext\Generators\Po::convertString |
( |
|
$value | ) |
|
|
static |
Convert a string to its PO representation.
- Parameters
-
- Returns
- string
Definition at line 123 of file Po.php.
◆ multilineQuote()
static Gettext\Generators\Po::multilineQuote |
( |
|
$string | ) |
|
|
staticprivate |
Escapes and adds double quotes to a string.
- Parameters
-
- Returns
- string
Definition at line 78 of file Po.php.
80 $lines = explode(
"\n", $string);
81 $last = count($lines) - 1;
83 foreach ($lines as $k => $line) {
85 $lines[$k] = self::convertString($line);
87 $lines[$k] = self::convertString($line.
"\n");
◆ toString()
static Gettext\Generators\Po::toString |
( |
Translations |
$translations | ) |
|
|
static |
{}.
Implements Gettext\Generators\GeneratorInterface.
Definition at line 12 of file Po.php.
References $comment, $name, and Gettext\Translations\getHeaders().
14 $lines = array(
'msgid ""',
'msgstr ""');
16 $headers = $translations->getHeaders();
17 $headers[
'PO-Revision-Date'] = date(
'c');
19 foreach ($headers as
$name => $value) {
20 $lines[] =
'"'.$name.
': '.$value.
'\\n"';
26 foreach ($translations as $translation) {
27 if ($translation->hasComments()) {
28 foreach ($translation->getComments() as
$comment) {
29 $lines[] =
'# '.$comment;
33 if ($translation->hasExtractedComments()) {
34 foreach ($translation->getExtractedComments() as
$comment) {
35 $lines[] =
'#. '.$comment;
39 if ($translation->hasReferences()) {
40 foreach ($translation->getReferences() as $reference) {
41 $lines[] =
'#: '.$reference[0].(!is_null($reference[1]) ?
':'.$reference[1] : null);
45 if ($translation->hasFlags()) {
46 $lines[] =
'#, '.implode(
',', $translation->getFlags());
49 if ($translation->hasContext()) {
50 $lines[] =
'msgctxt '.self::convertString($translation->getContext());
53 self::addLines($lines,
'msgid', $translation->getOriginal());
54 if ($translation->hasPlural()) {
55 self::addLines($lines,
'msgid_plural', $translation->getPlural());
56 self::addLines($lines,
'msgstr[0]', $translation->getTranslation());
58 foreach ($translation->getPluralTranslation() as $k => $v) {
59 self::addLines($lines,
'msgstr['.($k + 1).
']', $v);
62 self::addLines($lines,
'msgstr', $translation->getTranslation());
68 return implode(
"\n", $lines);
The documentation for this class was generated from the following file:
- libs/composer/vendor/gettext/gettext/src/Generators/Po.php