@@ -28,20 +28,7 @@ protected function _parse()
28
28
if ((string )$ attributes ['translate ' ] === 'true ' || (string )$ attributes ['translatable ' ] === 'true ' ) {
29
29
$ this ->_addPhrase ((string )$ element );
30
30
} else {
31
- $ nodesDelimiter = strpos ($ attributes ['translate ' ], ' ' ) === false ? ', ' : ' ' ;
32
- foreach (explode ($ nodesDelimiter , $ attributes ['translate ' ]) as $ value ) {
33
- $ phrase = (string )$ element ->{$ value };
34
- if ($ phrase ) {
35
- $ this ->_addPhrase ($ phrase );
36
- }
37
- $ elementAttributes = $ element ->attributes ();
38
- if (isset ($ elementAttributes [$ value ])) {
39
- $ phrase = (string )$ elementAttributes [$ value ];
40
- if ($ phrase ) {
41
- $ this ->_addPhrase ($ phrase );
42
- }
43
- }
44
- }
31
+ $ this ->parseTranslatableNodes ($ attributes , $ element );
45
32
}
46
33
}
47
34
}
@@ -66,4 +53,29 @@ protected function _getNodes($file)
66
53
67
54
return [];
68
55
}
56
+
57
+ /**
58
+ * Parse nodes pointed out in attribute "translate".
59
+ *
60
+ * @param $attributes
61
+ * @param $element
62
+ * @return void
63
+ */
64
+ protected function parseTranslatableNodes ($ attributes , $ element )
65
+ {
66
+ $ nodesDelimiter = strpos ($ attributes ['translate ' ], ' ' ) === false ? ', ' : ' ' ;
67
+ foreach (explode ($ nodesDelimiter , $ attributes ['translate ' ]) as $ value ) {
68
+ $ phrase = (string )$ element ->{$ value };
69
+ if ($ phrase ) {
70
+ $ this ->_addPhrase ($ phrase );
71
+ }
72
+ $ elementAttributes = $ element ->attributes ();
73
+ if (isset ($ elementAttributes [$ value ])) {
74
+ $ phrase = (string )$ elementAttributes [$ value ];
75
+ if ($ phrase ) {
76
+ $ this ->_addPhrase ($ phrase );
77
+ }
78
+ }
79
+ }
80
+ }
69
81
}
0 commit comments