ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
YamlDictionary.php
Go to the documentation of this file.
1<?php
2
3namespace Gettext\Generators;
4
7
9{
13 public static function toString(Translations $translations)
14 {
15 $array = PhpArray::toArray($translations);
16
17 //for a simple json translation dictionary, one domain is supported
18 $values = current($array);
19
20 // remove meta / header data
21 if (array_key_exists('', $values)) {
22 unset($values['']);
23 }
24
25 //map to a simple yml dictionary (no plurals)
26 $yml = new Dumper();
27 $output = $yml->dump(
28 array_map(
29 function ($val) {
30 return isset($val[1]) ? $val[1] : null;
31 },
33 ),
34 1
35 );
36
37 return $output;
38 }
39}
An exception for terminatinating execution or to throw for unit testing.
static toString(Translations $translations)
{@parentDoc}.
Class to manage a collection of translations.
Dumper dumps PHP variables to YAML strings.
Definition: Dumper.php:20
toArray($value)
Wrap the given value in an array if it is no array.
$values