ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
PhpArray.php
Go to the documentation of this file.
1
<?
php
2
3
namespace
Gettext\Extractors
;
4
5
use
Exception
;
6
use
Gettext\Translations
;
7
11
class
PhpArray
extends
Extractor
implements
ExtractorInterface
12
{
21
public
static
function
fromFile
($file,
Translations
$translations = null)
22
{
23
if
($translations === null) {
24
$translations =
new
Translations
();
25
}
26
27
foreach
(self::getFiles($file) as $file) {
28
self::handleArray(include($file), $translations);
29
}
30
31
return
$translations;
32
}
33
37
public
static
function
fromString
($string,
Translations
$translations = null, $file =
''
)
38
{
39
throw
new
Exception
(
'PhpArray::fromString() cannot be called. Use PhpArray::fromFile()'
);
40
}
41
48
public
static
function
handleArray
(array $content,
Translations
$translations)
49
{
50
$content = current($content);
51
52
$translations_info = isset($content[
''
]) ? $content[
''
] : null;
53
unset($content[
''
]);
54
55
if
(isset($translations_info[
'domain'
])) {
56
$translations->
setDomain
($translations_info[
'domain'
]);
57
}
58
59
foreach
($content as
$key
=>
$message
) {
60
static::insertTranslation($translations,
$key
,
$message
);
61
}
62
}
63
71
protected
static
function
insertTranslation
(
Translations
$translations,
$key
,
$message
)
72
{
73
$context_glue =
'\u0004'
;
74
$key
= explode($context_glue,
$key
);
75
76
$context
= isset(
$key
[1]) ? array_shift(
$key
) :
''
;
77
$original = array_shift(
$key
);
78
$plural = array_shift(
$message
);
79
$translation = array_shift(
$message
);
80
$plural_translation = array_shift(
$message
);
81
82
$entry = $translations->
insert
(
$context
, $original, $plural);
83
$entry->setTranslation($translation);
84
$entry->setPluralTranslation($plural_translation);
85
}
86
}
Gettext\Translations\setDomain
setDomain($domain)
Set a new domain for this translations.
Definition:
Translations.php:274
$context
$context
Definition:
webdav.php:25
Translations
Gettext\Translations\insert
insert($context, $original, $plural='')
Creates and insert/merges a new translation.
Definition:
Translations.php:329
Gettext\Extractors\PhpArray\fromFile
static fromFile($file, Translations $translations=null)
Extract the translations from a file.
Definition:
PhpArray.php:21
Gettext\Extractors\PhpArray\fromString
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:
PhpArray.php:37
Gettext\Translations
Class to manage a collection of translations.
Definition:
Translations.php:11
Gettext\Extractors\PhpArray\handleArray
static handleArray(array $content, Translations $translations)
Handle an array of translations and append to the Translations instance.
Definition:
PhpArray.php:48
$message
catch(Exception $e) $message
Definition:
saml2-logout.php:34
Gettext\Extractors\PhpArray\insertTranslation
static insertTranslation(Translations $translations, $key, $message)
Extract and insert a new translation.
Definition:
PhpArray.php:71
Gettext\Extractors\Extractor
Definition:
Extractor.php:9
Gettext\Extractors\ExtractorInterface
Definition:
ExtractorInterface.php:7
Gettext\Extractors\PhpArray
Class to get gettext strings from php files returning arrays.
Definition:
PhpArray.php:11
php
Gettext\Extractors
Definition:
Blade.php:3
$key
$key
Definition:
croninfo.php:18
Exception
libs
composer
vendor
gettext
gettext
src
Extractors
PhpArray.php
Generated on Thu Jan 16 2025 19:01:40 for ILIAS by
1.8.13 (using
Doxyfile
)