-
Notifications
You must be signed in to change notification settings - Fork 16
/
Patch-Magento-Framework-Translate_M2.2.5-theme-inherit-translations.patch
84 lines (82 loc) · 2.31 KB
/
Patch-Magento-Framework-Translate_M2.2.5-theme-inherit-translations.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
--- Translate.php
+++ Translate.php
@@ -328,17 +328,78 @@ class Translate implements \Magento\Framework\TranslateInterface
/**
* Load current theme translation
+ * Fix: Child theme does not inherit translations from parent theme
*
* @return $this
*/
protected function _loadThemeTranslation()
{
- $file = $this->_getThemeTranslationFile($this->getLocale());
- if ($file) {
- $this->_addData($this->_getFileData($file));
+ $themeFiles = $this->getThemeTranslationFilesList($this->getLocale());
+
+ /** @var string $file */
+ foreach ($themeFiles as $file) {
+ if ($file) {
+ $this->_addData($this->_getFileData($file));
+ }
}
+
return $this;
}
+
+ /**
+ *
+ * Fix: Child theme does not inherit translations from parent theme
+ *
+ */
+ private function getThemeTranslationFilesList($locale)
+ {
+ $translationFiles = [];
+
+ /** @var \Magento\Framework\View\Design\ThemeInterface $theme */
+ foreach ($this->getParentThemesList() as $theme) {
+ $config = $this->_config;
+ $config['theme'] = $theme->getCode();
+ $translationFiles[] = $this->getThemeTranslationFileName($locale, $config);
+ }
+
+ $translationFiles[] = $this->getThemeTranslationFileName($locale, $this->_config);
+
+ return $translationFiles;
+ }
+
+
+ /**
+ *
+ * Fix: Child theme does not inherit translations from parent theme
+ *
+ */
+ private function getParentThemesList()
+ {
+ $themes = [];
+
+ $parentTheme = $this->_viewDesign->getDesignTheme()->getParentTheme();
+ while($parentTheme) {
+ $themes[] = $parentTheme;
+ $parentTheme = $parentTheme->getParentTheme();
+ }
+ $themes = array_reverse($themes);
+
+ return $themes;
+ }
+
+ /**
+ *
+ * Fix: Child theme does not inherit translations from parent theme
+ *
+ */
+ private function getThemeTranslationFileName($locale, $config)
+ {
+ return $this->_viewFileSystem->getLocaleFileName(
+ 'i18n' . '/' . $locale . '.csv',
+ $config
+ );
+ }
+
/**
* Load translation dictionary from language packages