/** * @param $code * @param null $locale * * @return string */ public function locale($code, $locale = null) { $locales = Locale::getDisplayLocales($locale ?: $this->localeDetector->getLocale()); if (array_key_exists($code, $locales)) { return $this->fixCharset($locales[$code]); } return ''; }
public function testGetDisplayLocalesReturnsFullListForSubLocale() { $this->skipIfIntlExtensionIsNotLoaded(); $localesDe = Locale::getDisplayLocales('de'); $localesDeCh = Locale::getDisplayLocales('de_CH'); $this->assertEquals(count($localesDe), count($localesDeCh)); $this->assertEquals($localesDe['be'], 'Weißrussisch'); $this->assertEquals($localesDeCh['be'], 'Weissrussisch'); }
/** * {@inheritDoc} */ public function getViewData($request) { $user = $this->getUser(); $widgets = array(); $translator = $this->get('translator'); // WYSIWYG $currentEditor = $this->container->get('adminUserPrefService')->getPrefForName($user->getId(), 'wysiwygEditor'); $widgets[] = Beans::getBean('EditorSelectFormWidget#title=' . $translator->trans('Preferred Editor') . '&value=' . $currentEditor . '&name=wysiwygEditor'); // uiLocale (@todo fold into widget) $currentLocale = $this->container->get('adminUserPrefService')->getPrefForName($user->getId(), 'uiLocale'); $locales = Locale::getDisplayLocales($currentLocale); $uiLocaleWidget = Beans::getBean('selectFormWidget#name=uiLocale&title=' . $translator->trans('Admin Locale') . '&value=' . $currentLocale); foreach ($locales as $locale => $name) { // @todo decide whether to show the localized names here at all. $uiLocaleWidget->addOption('(' . $locale . ') ' . $name, $locale); } $uiLocaleWidget->setValue($this->container->get('adminUserPrefService')->getPrefForName($user->getId(), 'uiLocale')); $widgets[] = $uiLocaleWidget; return array('widgets' => $widgets); }
public function testGetDisplayLocales() { $locales = Locale::getDisplayLocales('en'); $this->assertEquals('Portuguese', $locales['pt']); }
/** * {@inheritdoc} */ public function getDefaultOptions(array $options) { return array('choices' => Locale::getDisplayLocales(\Locale::getDefault()), 'value_strategy' => ChoiceList::COPY_CHOICE); }
/** * @inheritDoc */ protected function configure() { $this->addOption('choices', Locale::getDisplayLocales(\Locale::getDefault())); parent::configure(); }
public function getDefaultOptions(array $options) { return array( 'choices' => Locale::getDisplayLocales(\Locale::getDefault()), ); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array('choices' => Locale::getDisplayLocales(\Locale::getDefault()))); }
/** * Returns the locale names for locale * * @return array The locale names with their codes as keys */ public function getDisplayLocales() { return SymfonyLocale::getDisplayLocales($this->getLocale()); }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $choices = array_intersect_key(Locale::getDisplayLocales(\Locale::getDefault()), $this->locales); $resolver->setDefaults(array('choices' => $choices)); }