ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Jed.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Gettext\Extractors;
4 
6 
10 class 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 }
static fromString($string, Translations $translations=null, $file='')
{Parses a string and append the translations found in the Translations instance.The file path to inse...
Definition: Jed.php:15
insert($context, $original, $plural='')
Creates and insert/merges a new translation.
Class to get gettext strings from json files.
Definition: Jed.php:10
Class to manage a collection of translations.
static handleArray(array $content, Translations $translations)
Handle an array of translations and append to the Translations instance.
Definition: PhpArray.php:48
catch(Exception $e) $message
static insertTranslation(Translations $translations, $key, $message)
Extract and insert a new translation.
Definition: Jed.php:35
Class to get gettext strings from php files returning arrays.
Definition: PhpArray.php:11
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
$key
Definition: croninfo.php:18