ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Gettext\Generators\CsvDictionary Class Reference
+ Inheritance diagram for Gettext\Generators\CsvDictionary:
+ Collaboration diagram for Gettext\Generators\CsvDictionary:

Static Public Member Functions

static toString (Translations $translations)
 {@parentDoc}. More...
 
- Static Public Member Functions inherited from Gettext\Generators\Generator
static toFile (Translations $translations, $file)
 Saves the translations in a file. More...
 
- Static Public Member Functions inherited from Gettext\Generators\GeneratorInterface
static toFile (Translations $translations, $file)
 Saves the translations in a file. More...
 
static toString (Translations $translations)
 Generates a string with the translations ready to save in a file. More...
 

Detailed Description

Definition at line 7 of file CsvDictionary.php.

Member Function Documentation

◆ toString()

static Gettext\Generators\CsvDictionary::toString ( Translations  $translations)
static

{@parentDoc}.

Implements Gettext\Generators\GeneratorInterface.

Definition at line 12 of file CsvDictionary.php.

13 {
14 $array = PhpArray::toArray($translations);
15
16 //for a simple json translation dictionary, one domain is supported
17 $values = current($array);
18
19 // remove meta / header data
20 if (array_key_exists('', $values)) {
21 unset($values['']);
22 }
23
24 $handle = fopen('php://memory', 'w');
25
26 //map to a simple csv dictionary (no plurals)
27 foreach ($values as $original => $translated) {
28 if (!isset($translated[1])) {
29 $translated[1] = '';
30 }
31 fputcsv($handle, array($original, $translated[1]));
32 }
33
34 rewind($handle);
35 $csv = stream_get_contents($handle);
36
37 fclose($handle);
38
39 return $csv;
40 }
toArray($value)
Wrap the given value in an array if it is no array.
$values

References $values, and ILIAS\UI\Implementation\Component\toArray().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: