public function registerValidatorTranslator(GetResponseEvent $event) { /** @var \Thelia\Core\HttpFoundation\Request $request */ $request = $event->getRequest(); $lang = $request->getSession()->getLang(); $vendorFormDir = THELIA_VENDOR . 'symfony' . DS . 'form' . DS . 'Symfony' . DS . 'Component' . DS . 'Form'; $vendorValidatorDir = THELIA_VENDOR . 'symfony' . DS . 'validator' . DS . 'Symfony' . DS . 'Component' . DS . 'Validator'; $this->translator->addResource('xlf', sprintf($vendorFormDir . DS . 'Resources' . DS . 'translations' . DS . 'validators.%s.xlf', $lang->getCode()), $lang->getLocale(), 'validators'); $this->translator->addResource('xlf', sprintf($vendorValidatorDir . DS . 'Resources' . DS . 'translations' . DS . 'validators.%s.xlf', $lang->getCode()), $lang->getLocale(), 'validators'); }
/** * @param InputInterface $input * @return array */ protected function initLocales(InputInterface $input) { $this->locales = []; $availableLocales = []; $finder = Finder::create()->name('*.php')->depth(0)->sortByName()->in(THELIA_SETUP_DIRECTORY . 'I18n'); // limit to only some locale(s) $localesToKeep = $input->getOption("locales"); if (!empty($localesToKeep)) { $localesToKeep = explode(',', $localesToKeep); } else { $localesToKeep = null; } /** @var \SplFileInfo $file */ foreach ($finder as $file) { $locale = $file->getBasename('.php'); $availableLocales[] = $locale; if (empty($localesToKeep) || in_array($locale, $localesToKeep)) { $this->locales[] = $locale; $this->translator->addResource('php', $file->getRealPath(), $locale, 'install'); } } if (empty($this->locales)) { throw new \RuntimeException(sprintf("You should at least generate sql for one locale. Available locales : %s", implode(', ', $availableLocales))); } }