/** * Transform content and/or content type for the specified preprocessing chain object * * @param Chain $chain * @return void */ public function process(Chain $chain) { if ($this->isDictionaryPath($chain->getTargetAssetPath())) { $context = $chain->getAsset()->getContext(); $themePath = $context instanceof FallbackContext ? $context->getThemePath() : '*/*'; $chain->setContent(json_encode($this->dataProvider->getData($themePath))); $chain->setContentType('json'); } }
/** * Transform content and/or content type for the specified preprocessing chain object * * @param Chain $chain * @return void */ public function process(Chain $chain) { if ($this->isDictionaryPath($chain->getTargetAssetPath())) { $context = $chain->getAsset()->getContext(); $themePath = '*/*'; $areaCode = \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE; if ($context instanceof FallbackContext) { $themePath = $context->getThemePath(); $areaCode = $context->getAreaCode(); $this->translate->setLocale($context->getLocale()); } $area = $this->areaList->getArea($areaCode); $area->load(\Magento\Framework\App\Area::PART_TRANSLATE); $chain->setContent(json_encode($this->dataProvider->getData($themePath))); $chain->setContentType('json'); } }