/** * Switch backend locale according to locale code * * @param string $localeCode * @return $this */ public function switchBackendInterfaceLocale($localeCode) { $this->_session->setSessionLocale(null); $this->_authSession->getUser()->setInterfaceLocale($localeCode); $this->_translator->setLocale($localeCode)->loadData(null, true); return $this; }
/** * Transform content and/or content type for the specified preprocessing chain object * * @param Chain $chain * @return void */ public function process(Chain $chain) { if ($this->config->isEmbeddedStrategy()) { $context = $chain->getAsset()->getContext(); $areaCode = \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE; if ($context instanceof FallbackContext) { $areaCode = $context->getAreaCode(); $this->translate->setLocale($context->getLocale()); } $area = $this->areaList->getArea($areaCode); $area->load(\Magento\Framework\App\Area::PART_TRANSLATE); $chain->setContent($this->translate($chain->getContent())); } }
/** * Restore locale of the initial store * * @param string $initialLocaleCode * @param string $initialArea * @return $this */ protected function _restoreInitialLocale($initialLocaleCode, $initialArea = \Magento\Framework\App\Area::AREA_ADMIN) { $this->_localeResolver->setLocale($initialLocaleCode); $this->_translate->setLocale($initialLocaleCode); $this->_translate->loadData($initialArea); return $this; }
/** * 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'); } }
/** * @param string|null $localeCode * @return void */ protected function _init($localeCode) { if ($localeCode !== null) { $this->_translate->setLocale($localeCode)->loadData(); } }
/** * @param string|null $localeCode * @return void */ protected function _init($localeCode) { if (!is_null($localeCode)) { $this->_translate->setLocale($localeCode)->loadData(null, true); } }