ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Gettext\Extractors\Jed Class Reference

Class to get gettext strings from json files. More...

+ Inheritance diagram for Gettext\Extractors\Jed:
+ Collaboration diagram for Gettext\Extractors\Jed:

Static Public Member Functions

static fromString ($string, Translations $translations=null, $file='')
 {Parses a string and append the translations found in the Translations instance.
Parameters
string$string
Translations | null$translations
string$fileThe file path to insert the reference
Returns
Translations
} More...
 
- Static Public Member Functions inherited from Gettext\Extractors\PhpArray
static fromFile ($file, Translations $translations=null)
 Extract the translations from a file. More...
 
static fromString ($string, Translations $translations=null, $file='')
 {Parses a string and append the translations found in the Translations instance.
Parameters
string$string
Translations | null$translations
string$fileThe file path to insert the reference
Returns
Translations
} More...
 
static handleArray (array $content, Translations $translations)
 Handle an array of translations and append to the Translations instance. More...
 
- Static Public Member Functions inherited from Gettext\Extractors\Extractor
static fromFile ($file, Translations $translations=null)
 Extract the translations from a file. More...
 

Static Protected Member Functions

static insertTranslation (Translations $translations, $key, $message)
 Extract and insert a new translation. More...
 
- Static Protected Member Functions inherited from Gettext\Extractors\PhpArray
static insertTranslation (Translations $translations, $key, $message)
 Extract and insert a new translation. More...
 
- Static Protected Member Functions inherited from Gettext\Extractors\Extractor
static getFiles ($file)
 Checks and returns all files. More...
 
static readFile ($file)
 Reads and returns the content of a file. More...
 

Detailed Description

Class to get gettext strings from json files.

Definition at line 10 of file Jed.php.

Member Function Documentation

◆ fromString()

static Gettext\Extractors\Jed::fromString (   $string,
Translations  $translations = null,
  $file = '' 
)
static

{Parses a string and append the translations found in the Translations instance.

Parameters
string$string
Translations | null$translations
string$fileThe file path to insert the reference
Returns
Translations
}

Implements Gettext\Extractors\ExtractorInterface.

Definition at line 15 of file Jed.php.

References Gettext\Extractors\PhpArray\handleArray().

16  {
17  if ($translations === null) {
18  $translations = new Translations();
19  }
20 
21  $content = json_decode($string, true);
22 
23  PhpArray::handleArray($content, $translations);
24 
25  return $translations;
26  }
static handleArray(array $content, Translations $translations)
Handle an array of translations and append to the Translations instance.
Definition: PhpArray.php:48
+ Here is the call graph for this function:

◆ insertTranslation()

static Gettext\Extractors\Jed::insertTranslation ( Translations  $translations,
  $key,
  $message 
)
staticprotected

Extract and insert a new translation.

Parameters
Translations$translations
string$key
string$message

Definition at line 35 of file Jed.php.

References $key, $message, and Gettext\Translations\insert().

36  {
37  $context_glue = '\u0004';
38  $key = explode($context_glue, $key);
39 
40  $context = isset($key[1]) ? array_shift($key) : '';
41  $original = array_shift($key);
42  $translation = array_shift($message);
43  $plural_translation = array_shift($message);
44 
45  $entry = $translations->insert($context, $original);
46  $entry->setTranslation($translation);
47  $entry->setPluralTranslation($plural_translation);
48  }
catch(Exception $e) $message
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

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