@@ -22,7 +22,7 @@ class Html extends AbstractAdapter
2222 * @deprecated Not used anymore because of newly introduced constants
2323 * @see self::REGEX_I18N_BINDING and self::REGEX_TRANSLATE_TAG_OR_ATTR
2424 */
25- const HTML_FILTER = "/i18n:\s?'(?<value>[^' \\\\]*(?: \\\\.[^' \\\\]*)*)'/ " ;
25+ public const HTML_FILTER = "/i18n:\s?'(?<value>[^' \\\\]*(?: \\\\.[^' \\\\]*)*)'/ " ;
2626
2727 /**
2828 * Covers
@@ -50,6 +50,21 @@ protected function _parse()
5050 throw new Exception ('Failed to load file from disk. ' );
5151 }
5252
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+ {
5368 $ results = [];
5469 preg_match_all (Filter::CONSTRUCTION_PATTERN , $ data , $ results , PREG_SET_ORDER );
5570 for ($ i = 0 , $ count = count ($ results ); $ i < $ count ; $ i ++) {
@@ -61,15 +76,16 @@ protected function _parse()
6176
6277 $ quote = $ directive [1 ];
6378 $ 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 ]);
6482 }
6583 }
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 );
7084 }
7185
7286 /**
87+ * Extracts all phrases with the given regex in the given string.
88+ *
7389 * @param string $regex
7490 * @param string $data
7591 * @param int $expectedGroupsCount
0 commit comments