/** * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param string $locale */ public function __construct(\Magento\Framework\Locale\ConfigInterface $config, \Magento\Framework\Locale\ResolverInterface $localeResolver, $locale = null) { $this->_config = $config; $this->localeResolver = $localeResolver; if ($locale !== null) { $this->localeResolver->setLocale($locale); } }
/** * @param \Magento\Framework\App\State $appState * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver * @param \Magento\Framework\Locale\ConfigInterface $config * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param string $locale */ public function __construct(\Magento\Framework\App\State $appState, \Magento\Framework\App\ScopeResolverInterface $scopeResolver, \Magento\Framework\Locale\ConfigInterface $config, \Magento\Framework\Locale\ResolverInterface $localeResolver, $locale = null) { $this->_appState = $appState; $this->_scopeResolver = $scopeResolver; $this->_config = $config; $this->_localeResolver = $localeResolver; if ($locale !== null) { $this->_localeResolver->setLocale($locale); } }
/** * 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; }
/** * Check set locale * * @param string $localeCodeToCheck * @return void */ protected function _checkSetLocale($localeCodeToCheck) { $this->_model->setLocale(); $localeCode = $this->_model->getLocale(); $this->assertEquals($localeCode, $localeCodeToCheck); }