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

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

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

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\Extractor
static fromFile ($file, Translations $translations=null)
 Extract the translations from a file. More...
 
- Static Public Member Functions inherited from Gettext\Extractors\ExtractorInterface
static fromFile ($file, Translations $translations=null)
 Extract the translations from a file. More...
 

Additional Inherited Members

- 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 plain json.

Definition at line 10 of file CsvDictionary.php.

Member Function Documentation

◆ fromString()

static Gettext\Extractors\CsvDictionary::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 CsvDictionary.php.

References $row, and array.

16  {
17  if ($translations === null) {
18  $translations = new Translations();
19  }
20 
21  $handle = fopen('php://memory', 'w');
22 
23  fputs($handle, $string);
24  rewind($handle);
25 
26  $entries = array();
27  while ($row = fgetcsv($handle)) {
28  $entries[$row[0]] = $row[1];
29  }
30 
31  fclose($handle);
32 
33  if ($entries) {
34  foreach ($entries as $original => $translation) {
35  $translations->insert(null, $original)->setTranslation($translation);
36  }
37  }
38 
39  return $translations;
40  }
Create styles array
The data for the language used.

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