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