本文整理匯總了PHP中Symfony\Component\Locale\Locale::getDisplayLocales方法的典型用法代碼示例。如果您正苦於以下問題:PHP Locale::getDisplayLocales方法的具體用法?PHP Locale::getDisplayLocales怎麽用?PHP Locale::getDisplayLocales使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Locale\Locale
的用法示例。
在下文中一共展示了Locale::getDisplayLocales方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: locale
/**
* @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 '';
}
示例2: testGetDisplayLocalesReturnsFullListForSubLocale
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');
}
示例3: getViewData
/**
* {@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);
}
示例4: testGetDisplayLocales
public function testGetDisplayLocales()
{
$locales = Locale::getDisplayLocales('en');
$this->assertEquals('Portuguese', $locales['pt']);
}
示例5: getDefaultOptions
/**
* {@inheritdoc}
*/
public function getDefaultOptions(array $options)
{
return array('choices' => Locale::getDisplayLocales(\Locale::getDefault()), 'value_strategy' => ChoiceList::COPY_CHOICE);
}
示例6: configure
/**
* @inheritDoc
*/
protected function configure()
{
$this->addOption('choices', Locale::getDisplayLocales(\Locale::getDefault()));
parent::configure();
}
示例7: getDefaultOptions
public function getDefaultOptions(array $options)
{
return array(
'choices' => Locale::getDisplayLocales(\Locale::getDefault()),
);
}
示例8: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('choices' => Locale::getDisplayLocales(\Locale::getDefault())));
}
示例9: getDisplayLocales
/**
* Returns the locale names for locale
*
* @return array The locale names with their codes as keys
*/
public function getDisplayLocales()
{
return SymfonyLocale::getDisplayLocales($this->getLocale());
}
示例10: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$choices = array_intersect_key(Locale::getDisplayLocales(\Locale::getDefault()), $this->locales);
$resolver->setDefaults(array('choices' => $choices));
}