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

Static Public Member Functions

static toString (Translations $translations)
 {Generates a string with the translations ready to save in a file.
Parameters
Translations$translations
Returns
string
} More...
 
static toArray (Translations $translations)
 Generates an array with the translations. 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 Protected Member Functions

static buildArray (Translations $translations)
 Generates an array with all translations. More...
 

Detailed Description

Definition at line 7 of file PhpArray.php.

Member Function Documentation

◆ buildArray()

static Gettext\Generators\PhpArray::buildArray ( Translations  $translations)
staticprotected

Generates an array with all translations.

Parameters
Translations$translations
Returns
array

Definition at line 59 of file PhpArray.php.

References $key.

60  {
61  $array = array();
62 
63  $context_glue = "\004";
64 
65  foreach ($translations as $translation) {
66  $key = ($translation->hasContext() ? $translation->getContext().$context_glue : '').$translation->getOriginal();
67  $entry = array($translation->getPlural(), $translation->getTranslation());
68 
69  if ($translation->hasPluralTranslation()) {
70  $entry = array_merge($entry, $translation->getPluralTranslation());
71  }
72 
73  $array[$key] = $entry;
74  }
75 
76  return $array;
77  }
$key
Definition: croninfo.php:18

◆ toArray()

static Gettext\Generators\PhpArray::toArray ( Translations  $translations)
static

Generates an array with the translations.

Parameters
Translations$translations
Returns
array

Definition at line 26 of file PhpArray.php.

References $domain, $lang, Gettext\Translations\getDomain(), Gettext\Translations\getHeader(), and Gettext\Translations\getLanguage().

Referenced by Gettext\Generators\CsvDictionary\toString(), Gettext\Generators\YamlDictionary\toString(), and Gettext\Generators\JsonDictionary\toString().

27  {
28  $array = static::buildArray($translations);
29 
30  $domain = $translations->getDomain() ?: 'messages';
31  $lang = $translations->getLanguage() ?: 'en';
32 
33  $fullArray = array(
34  $domain => array(
35  '' => array(
36  'domain' => $domain,
37  'lang' => $lang,
38  'plural-forms' => 'nplurals=2; plural=(n != 1);',
39  ),
40  ),
41  );
42 
43  if ($translations->getHeader('Plural-Forms') !== null) {
44  $fullArray[$domain]['']['plural-forms'] = $translations->getHeader('Plural-Forms');
45  }
46 
47  $fullArray[$domain] = array_merge($fullArray[$domain], $array);
48 
49  return $fullArray;
50  }
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
if(!array_key_exists('domain', $_REQUEST)) $domain
Definition: resume.php:8
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toString()

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

{Generates a string with the translations ready to save in a file.

Parameters
Translations$translations
Returns
string
}

Implements Gettext\Generators\GeneratorInterface.

Definition at line 12 of file PhpArray.php.

References ILIAS\UI\Implementation\Component\toArray().

13  {
14  $array = self::toArray($translations);
15 
16  return '<?php return '.var_export($array, true).'; ?>';
17  }
toArray($value)
Wrap the given value in an array if it is no array.
+ Here is the call graph for this function:

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