ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Gettext\Utils\FunctionsScanner Class Reference
+ Inheritance diagram for Gettext\Utils\FunctionsScanner:
+ Collaboration diagram for Gettext\Utils\FunctionsScanner:

Public Member Functions

 getFunctions ()
 Scan and returns the functions and the arguments. More...
 
 saveGettextFunctions (array $functions, Translations $translations, $file='')
 Search for specific functions and create translations. More...
 

Detailed Description

Definition at line 8 of file FunctionsScanner.php.

Member Function Documentation

◆ getFunctions()

Gettext\Utils\FunctionsScanner::getFunctions ( )
abstract

Scan and returns the functions and the arguments.

Returns
array

Reimplemented in Gettext\Utils\JsFunctionsScanner, and Gettext\Utils\PhpFunctionsScanner.

Referenced by Gettext\Utils\FunctionsScanner\saveGettextFunctions().

+ Here is the caller graph for this function:

◆ saveGettextFunctions()

Gettext\Utils\FunctionsScanner::saveGettextFunctions ( array  $functions,
Translations  $translations,
  $file = '' 
)

Search for specific functions and create translations.

Parameters
array$functionsThe gettext functions to search
Translations$translationsThe translations instance where save the values
string$fileThe filename used to the reference

Definition at line 24 of file FunctionsScanner.php.

25 {
26 foreach ($this->getFunctions() as $function) {
27 list($name, $line, $args) = $function;
28
29 if (!isset($functions[$name])) {
30 continue;
31 }
32
33 $translation = null;
34
35 switch ($functions[$name]) {
36 case '__':
37 if (!isset($args[0])) {
38 continue 2;
39 }
40
41 $original = $args[0];
42
43 if ($original !== '') {
44 $translation = $translations->insert('', $original);
45 }
46 break;
47
48 case 'n__':
49 if (!isset($args[1])) {
50 continue 2;
51 }
52
53 list($original, $plural) = $args;
54
55 if ($original !== '') {
56 $translation = $translations->insert('', $original, $plural);
57 }
58 break;
59
60 case 'p__':
61 if (!isset($args[1])) {
62 continue 2;
63 }
64
65 list($context, $original) = $args;
66
67 if ($original !== '') {
68 $translation = $translations->insert($context, $original);
69 }
70 break;
71
72 case 'd__':
73 if (!isset($args[1])) {
74 continue 2;
75 }
76
77 list($domain, $original) = $args;
78
79 if ($original !== '' && $domain === $translations->getDomain()) {
80 $translation = $translations->insert('', $original);
81 }
82 break;
83
84 case 'dp__':
85 if (!isset($args[2])) {
86 continue 2;
87 }
88
89 list($domain, $context, $original) = $args;
90
91 if ($original !== '' && $domain === $translations->getDomain()) {
92 $translation = $translations->insert($context, $original);
93 }
94 break;
95
96 case 'np__':
97 if (!isset($args[2])) {
98 continue 2;
99 }
100
101 list($context, $original, $plural) = $args;
102
103 if ($original !== '') {
104 $translation = $translations->insert($context, $original, $plural);
105 }
106 break;
107
108 case 'dnp__':
109 if (!isset($args[4])) {
110 continue 2;
111 }
112
113 list($domain, $context, $original, $plural) = $args;
114
115 if ($original !== '' && $domain === $translations->getDomain()) {
116 $translation = $translations->insert($context, $original, $plural);
117 }
118 break;
119
120 default:
121 throw new Exception('Not valid functions');
122 }
123
124 if (isset($translation)) {
125 $translation->addReference($file, $line);
126 if (isset($function[3])) {
127 foreach ($function[3] as $extractedComment) {
128 $translation->addExtractedComment($extractedComment);
129 }
130 }
131 }
132 }
133 }
$function
Definition: cas.php:28
if(!array_key_exists('domain', $_REQUEST)) $domain
Definition: resume.php:8
getFunctions()
Scan and returns the functions and the arguments.
if($format !==null) $name
Definition: metadata.php:146
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $domain, $file, $function, $name, Gettext\Translations\getDomain(), Gettext\Utils\FunctionsScanner\getFunctions(), and Gettext\Translations\insert().

+ Here is the call graph for this function:

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