@@ -22,7 +22,7 @@ class Html extends AbstractAdapter
22
22
* @deprecated Not used anymore because of newly introduced constants
23
23
* @see self::REGEX_I18N_BINDING and self::REGEX_TRANSLATE_TAG_OR_ATTR
24
24
*/
25
- const HTML_FILTER = "/i18n:\s?'(?<value>[^' \\\\]*(?: \\\\.[^' \\\\]*)*)'/ " ;
25
+ public const HTML_FILTER = "/i18n:\s?'(?<value>[^' \\\\]*(?: \\\\.[^' \\\\]*)*)'/ " ;
26
26
27
27
/**
28
28
* Covers
@@ -50,6 +50,21 @@ protected function _parse()
50
50
throw new Exception ('Failed to load file from disk. ' );
51
51
}
52
52
53
+ $ this ->extractPhrasesFromTransDirective ($ data );
54
+ $ this ->extractPhrases (self ::REGEX_I18N_BINDING , $ data , 2 , 1 );
55
+ $ this ->extractPhrases (self ::REGEX_TRANSLATE_TAG_OR_ATTR , $ data , 3 , 2 );
56
+ $ this ->extractPhrases (Js::REGEX_TRANSLATE_FUNCTION , $ data , 3 , 2 );
57
+ }
58
+
59
+ /**
60
+ * Extracts all phrases from trans directives in the given string.
61
+ *
62
+ * @param string $data
63
+ *
64
+ * @return void
65
+ */
66
+ private function extractPhrasesFromTransDirective (string $ data ): void
67
+ {
53
68
$ results = [];
54
69
preg_match_all (Filter::CONSTRUCTION_PATTERN , $ data , $ results , PREG_SET_ORDER );
55
70
for ($ i = 0 , $ count = count ($ results ); $ i < $ count ; $ i ++) {
@@ -61,15 +76,16 @@ protected function _parse()
61
76
62
77
$ quote = $ directive [1 ];
63
78
$ this ->_addPhrase ($ quote . $ directive [2 ] . $ quote );
79
+ } elseif (in_array ($ results [$ i ][1 ], ['depend ' , 'if ' ], true ) && isset ($ results [$ i ][3 ])) {
80
+ // make sure to process trans directives nested inside depend / if directives
81
+ $ this ->extractPhrasesFromTransDirective ($ results [$ i ][3 ]);
64
82
}
65
83
}
66
-
67
- $ this ->extractPhrases (self ::REGEX_I18N_BINDING , $ data , 2 , 1 );
68
- $ this ->extractPhrases (self ::REGEX_TRANSLATE_TAG_OR_ATTR , $ data , 3 , 2 );
69
- $ this ->extractPhrases (Js::REGEX_TRANSLATE_FUNCTION , $ data , 3 , 2 );
70
84
}
71
85
72
86
/**
87
+ * Extracts all phrases with the given regex in the given string.
88
+ *
73
89
* @param string $regex
74
90
* @param string $data
75
91
* @param int $expectedGroupsCount
0 commit comments