ILIAS
release_5-3 Revision v5.3.23-19-g915713cf615
◀ ilDoc Overview
Extractor.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Gettext\Extractors
;
4
5
use
Exception
;
6
use
InvalidArgumentException
;
7
use
Gettext\Translations
;
8
9
abstract
class
Extractor
10
{
19
public
static
function
fromFile
(
$file
,
Translations
$translations = null)
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
}
31
39
protected
static
function
getFiles
(
$file
)
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
)) {
58
$files
=
array
();
59
60
foreach
(
$file
as $f) {
61
$files
= array_merge(
$files
, self::getFiles($f));
62
}
63
64
return
$files
;
65
}
66
67
throw
new
InvalidArgumentException
(
'The first argumet must be string or array'
);
68
}
69
77
protected
static
function
readFile
(
$file
)
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
}
90
}
$files
$files
Definition:
add-vimline.php:18
Gettext\Extractors\Extractor\fromFile
static fromFile($file, Translations $translations=null)
Extract the translations from a file.
Definition:
Extractor.php:19
Gettext\Extractors\Extractor\getFiles
static getFiles($file)
Checks and returns all files.
Definition:
Extractor.php:39
Translations
Gettext\Translations
Class to manage a collection of translations.
Definition:
Translations.php:11
Gettext\Extractors\Extractor
Definition:
Extractor.php:9
array
Create styles array
The data for the language used.
Definition:
40duplicateStyle.php:19
InvalidArgumentException
$file
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
Definition:
rename-config.php:43
Gettext\Extractors
Definition:
Blade.php:3
Gettext\Extractors\Extractor\readFile
static readFile($file)
Reads and returns the content of a file.
Definition:
Extractor.php:77
Exception
libs
composer
vendor
gettext
gettext
src
Extractors
Extractor.php
Generated on Sat Jan 18 2025 19:01:04 for ILIAS by
1.8.13 (using
Doxyfile
)