150 \
Magento\Framework\View\DesignInterface $viewDesign,
152 \
Magento\Framework\View\FileSystem $viewFileSystem,
153 \
Magento\Framework\Module\ModuleList $moduleList,
154 \
Magento\Framework\Module\Dir\Reader $modulesReader,
155 \
Magento\Framework\
App\ScopeResolverInterface $scopeResolver,
157 \
Magento\Framework\Locale\ResolverInterface $locale,
165 $this->_viewDesign = $viewDesign;
167 $this->_viewFileSystem = $viewFileSystem;
168 $this->_moduleList = $moduleList;
169 $this->_modulesReader = $modulesReader;
170 $this->_scopeResolver = $scopeResolver;
171 $this->_translateResource = $translate;
172 $this->_locale = $locale;
173 $this->_appState = $appState;
176 $this->_csvParser = $csvParser;
178 $this->fileDriver = $fileDriver
182 self::CONFIG_AREA_KEY =>
null,
183 self::CONFIG_LOCALE_KEY =>
null,
184 self::CONFIG_SCOPE_KEY =>
null,
185 self::CONFIG_THEME_KEY =>
null,
186 self::CONFIG_MODULE_KEY =>
null,
197 public function loadData($area =
null, $forceReload =
false)
200 if ($area ===
null) {
201 $area = $this->_appState->getAreaCode();
205 self::CONFIG_AREA_KEY => $area,
211 if (
false !==
$data) {
212 $this->_data =
$data;
238 if (!isset($this->_config[self::CONFIG_LOCALE_KEY])) {
241 if (!isset($this->_config[self::CONFIG_SCOPE_KEY])) {
244 if (!isset($this->_config[self::CONFIG_THEME_KEY])) {
247 if (!isset($this->_config[self::CONFIG_MODULE_KEY])) {
260 $scope = ($this->
getConfig(self::CONFIG_AREA_KEY) ===
'adminhtml') ?
'admin' :
null;
261 return $this->_scopeResolver->getScope($scope)->getCode();
272 if (isset($this->_config[$key])) {
273 return $this->_config[$key];
284 return $this->request->getControllerModule();
295 $allModulesExceptCurrent = array_diff($this->_moduleList->getNames(), [$currentModule]);
310 foreach ($modules as $module) {
327 if (isset($this->_data[$key])) {
328 unset($this->_data[$key]);
333 $key = str_replace(
'""',
'"', $key);
336 $this->_data[$key] =
$value;
373 $data = $this->_translateResource->getTranslationArray(
null, $this->
getLocale());
374 $this->
_addData(array_map(
'htmlspecialchars_decode',
$data));
387 $file = $this->_modulesReader->getModuleDir(Module\Dir::MODULE_I18N_DIR, $moduleName);
388 $file .=
'/' . $locale .
'.csv';
400 return $this->_viewFileSystem->getLocaleFileName(
401 'i18n' .
'/' . $locale .
'.csv',
415 if ($this->fileDriver->isExists($file)) {
416 $this->_csvParser->setDelimiter(
',');
417 $data = $this->_csvParser->getDataPairs($file);
429 if ($this->_data ===
null) {
442 if (
null === $this->_localeCode) {
443 $this->_localeCode = $this->_locale->getLocale();
456 $this->_localeCode = $locale;
468 $theme = $this->request->getParam(self::CONFIG_THEME_KEY);
470 return self::CONFIG_THEME_KEY . $this->
getConfig(self::CONFIG_THEME_KEY);
472 return self::CONFIG_THEME_KEY .
$theme[
'theme_title'];
502 $data = $this->getSerializer()->unserialize(
$data);
514 $this->_cache->save($this->getSerializer()->serialize($this->
getData()), $this->
getCacheId(), [],
false);
524 private function getSerializer()
526 if ($this->serializer ===
null) {
528 ->get(
Serialize\SerializerInterface::class);
530 return $this->serializer;
getControllerModuleName()
__construct(\Magento\Framework\View\DesignInterface $viewDesign, \Magento\Framework\Cache\FrontendInterface $cache, \Magento\Framework\View\FileSystem $viewFileSystem, \Magento\Framework\Module\ModuleList $moduleList, \Magento\Framework\Module\Dir\Reader $modulesReader, \Magento\Framework\App\ScopeResolverInterface $scopeResolver, \Magento\Framework\Translate\ResourceInterface $translate, \Magento\Framework\Locale\ResolverInterface $locale, \Magento\Framework\App\State $appState, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\App\RequestInterface $request, \Magento\Framework\File\Csv $csvParser, \Magento\Framework\App\Language\Dictionary $packDictionary, DriverInterface $fileDriver=null)
_getModuleTranslationFile($moduleName, $locale)
loadModuleTranslationByModulesList(array $modules)
loadData($area=null, $forceReload=false)
_getThemeTranslationFile($locale)