55 */
66namespace Magento \Catalog \Model ;
77
8+ use \Magento \Framework \TranslateInterface ;
9+
810/**
911 * Catalog Custom Category design Model
1012 *
@@ -31,26 +33,44 @@ class Design extends \Magento\Framework\Model\AbstractModel
3133 */
3234 protected $ _localeDate ;
3335
36+ /**
37+ * @var \Magento\Framework\View\Design\ThemeInterfaceFactory
38+ */
39+ protected $ _themeFactory ;
40+
41+ /**
42+ * @var TranslateInterface
43+ */
44+ private $ translator ;
45+
3446 /**
3547 * @param \Magento\Framework\Model\Context $context
3648 * @param \Magento\Framework\Registry $registry
3749 * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
3850 * @param \Magento\Framework\View\DesignInterface $design
51+ * @param \Magento\Framework\View\Design\ThemeInterfaceFactory $themeFactory
3952 * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
4053 * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
54+ * @param TranslateInterface $translator
4155 * @param array $data
4256 */
4357 public function __construct (
4458 \Magento \Framework \Model \Context $ context ,
4559 \Magento \Framework \Registry $ registry ,
4660 \Magento \Framework \Stdlib \DateTime \TimezoneInterface $ localeDate ,
4761 \Magento \Framework \View \DesignInterface $ design ,
62+ \Magento \Framework \View \Design \ThemeInterfaceFactory $ themeFactory ,
4863 \Magento \Framework \Model \ResourceModel \AbstractResource $ resource = null ,
4964 \Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
50- array $ data = []
65+ array $ data = [],
66+ TranslateInterface $ translator = null
5167 ) {
5268 $ this ->_localeDate = $ localeDate ;
5369 $ this ->_design = $ design ;
70+ $ this ->_themeFactory = $ themeFactory ;
71+ $ this ->translator = $ translator ?:
72+ \Magento \Framework \App \ObjectManager::getInstance ()->get (TranslateInterface::class);
73+
5474 parent ::__construct ($ context , $ registry , $ resource , $ resourceCollection , $ data );
5575 }
5676
@@ -63,6 +83,20 @@ public function __construct(
6383 public function applyCustomDesign ($ design )
6484 {
6585 $ this ->_design ->setDesignTheme ($ design );
86+ $ this ->applyCustomDesingTranslations ($ design );
87+ return $ this ;
88+ }
89+
90+ /**
91+ * Apply custom design translations
92+ *
93+ * @param string $design
94+ * @return $this
95+ */
96+ private function applyCustomDesingTranslations ($ design )
97+ {
98+ $ theme = $ this ->_themeFactory ->create ()->load ($ design )->getThemePath ();
99+ $ this ->translator ->setTheme ($ theme )->loadData (null , true );
66100 return $ this ;
67101 }
68102
0 commit comments