ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Jed.php
Go to the documentation of this file.
1<?php
2
3namespace Gettext\Extractors;
4
6
10class Jed extends PhpArray implements ExtractorInterface
11{
15 public static function fromString($string, Translations $translations = null, $file = '')
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 }
27
35 protected static function insertTranslation(Translations $translations, $key, $message)
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 }
49}
An exception for terminatinating execution or to throw for unit testing.
Class to get gettext strings from json files.
Definition: Jed.php:11
static insertTranslation(Translations $translations, $key, $message)
Extract and insert a new translation.
Definition: Jed.php:35
static fromString($string, Translations $translations=null, $file='')
{Parses a string and append the translations found in the Translations instance.Translations}
Definition: Jed.php:15
Class to get gettext strings from php files returning arrays.
Definition: PhpArray.php:12
static handleArray(array $content, Translations $translations)
Handle an array of translations and append to the Translations instance.
Definition: PhpArray.php:48
Class to manage a collection of translations.
insert($context, $original, $plural='')
Creates and insert/merges a new translation.
$key
Definition: croninfo.php:18
catch(Exception $e) $message
$context
Definition: webdav.php:25