Definition at line 9 of file Extractor.php.
◆ fromFile()
static Gettext\Extractors\Extractor::fromFile |
( |
|
$file, |
|
|
Translations |
$translations = null |
|
) |
| |
|
static |
Extract the translations from a file.
- Parameters
-
array | string | $file | A path of a file or files |
null | Translations | $translations | The translations instance to append the new translations. |
- Returns
- Translations
Reimplemented in Gettext\Extractors\PhpArray.
Definition at line 19 of file Extractor.php.
20 {
21 if ($translations === null) {
22 $translations = new Translations();
23 }
24
25 foreach (self::getFiles($file) as $file) {
26 static::fromString(self::readFile($file), $translations, $file);
27 }
28
29 return $translations;
30 }
◆ getFiles()
static Gettext\Extractors\Extractor::getFiles |
( |
|
$file | ) |
|
|
staticprotected |
Checks and returns all files.
- Parameters
-
string | array | $file | The file/s |
- Returns
- array The file paths
Definition at line 39 of file Extractor.php.
40 {
41 if (empty($file)) {
42 throw new InvalidArgumentException('There is not any file defined');
43 }
44
45 if (is_string($file)) {
46 if (!is_file($file)) {
47 throw new InvalidArgumentException("'$file' is not a valid file");
48 }
49
50 if (!is_readable($file)) {
51 throw new InvalidArgumentException("'$file' is not a readable file");
52 }
53
54 return array($file);
55 }
56
57 if (is_array($file)) {
59
60 foreach ($file as
$f) {
62 }
63
65 }
66
67 throw new InvalidArgumentException('The first argumet must be string or array');
68 }
References $f, and $files.
◆ readFile()
static Gettext\Extractors\Extractor::readFile |
( |
|
$file | ) |
|
|
staticprotected |
Reads and returns the content of a file.
- Parameters
-
- Returns
- string
Definition at line 77 of file Extractor.php.
78 {
79 $length = filesize($file);
80
81 if (!($fd = fopen($file, 'rb'))) {
82 throw new Exception("Cannot read the file '$file', probably permissions");
83 }
84
85 $content = $length ? fread($fd, $length) : '';
86 fclose($fd);
87
88 return $content;
89 }
The documentation for this class was generated from the following file:
- libs/composer/vendor/gettext/gettext/src/Extractors/Extractor.php