/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('name', 'text', ['label' => 'orob2b.rfp.requeststatus.name.label', 'required' => true])->add('sortOrder', 'integer', ['label' => 'orob2b.rfp.requeststatus.sort_order.label', 'required' => true]); $lang = $this->localeSettings->getLanguage(); $notificationLangs = $this->userConfig->get('oro_locale.languages'); $notificationLangs = array_unique(array_merge($notificationLangs, [$lang])); $localeLabels = $this->localeSettings->getLocalesByCodes($notificationLangs, $lang); $builder->add('translations', 'orob2b_rfp_request_status_translation', ['label' => 'orob2b.rfp.requeststatus.label.label', 'required' => false, 'locales' => $notificationLangs, 'labels' => $localeLabels]); }
/** * @param Request $request */ public function setRequest(Request $request = null) { if (!$request) { return; } if (!$request->attributes->get('_locale')) { $request->setLocale($this->localeSettings->getLanguage()); } $this->setPhpDefaultLocale($this->localeSettings->getLocale()); }
/** * Get the absolute filepath for JS translations. * If the file doesn't exist, it creates it. * * @return string */ public function getTranslationsFile() { $localeCode = $this->localeSettings->getLanguage(); $translationFilePath = sprintf('%s/js/translation/%s.js', $this->asseticRoot, $localeCode); $translationFilePath = realpath($translationFilePath); if (!file_exists($translationFilePath)) { $result = $this->commandLauncher->executeForeground(sprintf('oro:translation:dump %s', $localeCode)); if ($result->getCommandStatus() > 0) { throw new \RuntimeException(sprintf('Error during translations file generation for locale "%s"', $localeCode)); } } return $translationFilePath; }
/** * Gets instance of intl date formatter by parameters * * @param string|int|null $dateType * @param string|int|null $timeType * @param string|null $locale * @param string|null $timeZone * @param string|null $pattern * @return \IntlDateFormatter */ protected function getFormatter($dateType, $timeType, $locale, $timeZone, $pattern) { if (!$pattern) { $pattern = $this->getPattern($dateType, $timeType, $locale); } return new \IntlDateFormatter($this->localeSettings->getLanguage(), null, null, $timeZone, \IntlDateFormatter::GREGORIAN, $pattern); }
/** * Gets translated locale name by its code * * @param string|null $locale The locale code. NULL means default locale * * @return string */ protected function getLocaleName($locale) { $currentLang = $this->localeSettings->getLanguage(); if (empty($locale)) { $locale = $currentLang; } $localeNames = $this->localeSettings->getLocalesByCodes([$locale], $currentLang); return $localeNames[$locale]; }
/** * @param ConsoleCommandEvent $event */ public function onConsoleCommand(ConsoleCommandEvent $event) { $isForced = $event->getInput()->hasParameterOption('--force'); if ($isForced) { $this->isInstalled = false; return; } if ($this->isInstalled) { try { $locale = $this->localeSettings->getLocale(); $language = $this->localeSettings->getLanguage(); } catch (DBALException $exception) { // application is not installed return; } $this->setPhpDefaultLocale($locale); $this->translatableListener->setTranslatableLocale($language); } }
/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('name', 'text', array('label' => 'oro.email.emailtemplate.name.label', 'required' => true)); $builder->add('type', 'choice', array('label' => 'oro.email.emailtemplate.type.label', 'multiple' => false, 'expanded' => true, 'choices' => array('html' => 'oro.email.datagrid.emailtemplate.filter.type.html', 'txt' => 'oro.email.datagrid.emailtemplate.filter.type.txt'), 'required' => true)); $builder->add('entityName', 'oro_entity_choice', array('label' => 'oro.email.emailtemplate.entity_name.label', 'tooltip' => 'oro.email.emailtemplate.entity_name.tooltip', 'required' => false, 'configs' => ['allowClear' => true])); $lang = $this->localeSettings->getLanguage(); $notificationLangs = $this->userConfig->get('oro_locale.languages'); $notificationLangs = array_merge($notificationLangs, [$lang]); $localeLabels = $this->localeSettings->getLocalesByCodes($notificationLangs, $lang); $builder->add('translations', 'oro_email_emailtemplate_translatation', array('label' => 'oro.email.emailtemplate.translations.label', 'required' => false, 'locales' => $notificationLangs, 'labels' => $localeLabels)); $builder->add('parentTemplate', 'hidden', array('label' => 'oro.email.emailtemplate.parent.label', 'property_path' => 'parent')); // disable some fields for non editable email template $setDisabled = function (&$options) { if (isset($options['auto_initialize'])) { $options['auto_initialize'] = false; } $options['disabled'] = true; }; $factory = $builder->getFormFactory(); $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use($factory, $setDisabled) { $data = $event->getData(); if ($data && $data->getId() && $data->getIsSystem()) { $form = $event->getForm(); // entityName field $options = $form->get('entityName')->getConfig()->getOptions(); $setDisabled($options); $form->add($factory->createNamed('entityName', 'oro_entity_choice', null, $options)); // name field $options = $form->get('name')->getConfig()->getOptions(); $setDisabled($options); $form->add($factory->createNamed('name', 'text', null, $options)); if (!$data->getIsEditable()) { // name field $options = $form->get('type')->getConfig()->getOptions(); $setDisabled($options); $form->add($factory->createNamed('type', 'choice', null, $options)); } } }); }
/** * @param string $expectedValue * @param string $configurationValue * @dataProvider getLanguageDataProvider */ public function testGetLanguage($expectedValue, $configurationValue) { $this->configManager->expects($this->once())->method('get')->with('oro_locale.language')->will($this->returnValue($configurationValue)); $this->assertEquals($expectedValue, $this->localeSettings->getLanguage()); }
/** * @return array */ protected function getLocaleLabels() { return $this->localeSettings->getLocalesByCodes($this->getLanguages(), $this->localeSettings->getLanguage()); }