Skip to content

Commit 6c62b13

Browse files
committed
Merge remote-tracking branch 'origin/AC-3226' into Spartans_2_4_6_Quality_Backlog
2 parents e235082 + 2da2a9b commit 6c62b13

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

setup/src/Magento/Setup/Module/I18n/Parser/Adapter/Xml.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,22 @@
1616
class Xml extends AbstractAdapter
1717
{
1818
/**
19-
* {@inheritdoc}
19+
* @inheritdoc
2020
*/
2121
protected function _parse()
2222
{
23-
foreach ($this->_getNodes($this->_file) as $element) {
23+
foreach ($this->_getNodes($this->_file) as $key => $element) {
24+
2425
if (!$element instanceof \SimpleXMLElement) {
2526
continue;
2627
}
28+
2729
$attributes = $element->attributes();
30+
2831
if ((string)$attributes['translate'] === 'true' || (string)$attributes['translatable'] === 'true') {
2932
$this->_addPhrase((string)$element);
33+
} elseif ($key === 'title') {
34+
$this->_addPhrase((string)$element->title);
3035
} else {
3136
$this->parseTranslatableNodes($attributes, $element);
3237
}
@@ -44,8 +49,15 @@ protected function _getNodes($file)
4449
libxml_use_internal_errors(true);
4550
$xml = simplexml_load_file($file);
4651
libxml_use_internal_errors(false);
52+
4753
if ($xml) {
4854
$nodes = $xml->xpath('//*[@translate|@translatable]');
55+
56+
/* To add title of all xml files in translation csv */
57+
if ($xml->head) {
58+
$nodes['title'] = $xml->head;
59+
}
60+
4961
unset($xml);
5062

5163
return is_array($nodes) ? $nodes : [];

setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/XmlTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function parseDataProvider()
6060
['phrase' => 'Phrase 3', 'file' => $default, 'line' => '', 'quote' => ''],
6161
['phrase' => 'Phrase 1', 'file' => $default, 'line' => '', 'quote' => ''],
6262
['phrase' => 'Comment from new line.', 'file' => $default, 'line' => '', 'quote' => ''],
63+
['phrase' => 'Title', 'file' => $default, 'line' => '', 'quote' => ''],
6364
],
6465
],
6566
[

setup/src/Magento/Setup/Test/Unit/Module/I18n/Parser/Adapter/_files/default.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
-->
88

99
<layout>
10+
<head>
11+
<title>Title</title>
12+
</head>
1013
<node1 translate="description, label">
1114
<description>Phrase 1</description>
1215
<label>Phrase 2</label>

0 commit comments

Comments
 (0)