本文整理汇总了PHP中Symfony\Component\Locale\Locale::getDisplayLanguages方法的典型用法代码示例。如果您正苦于以下问题:PHP Locale::getDisplayLanguages方法的具体用法?PHP Locale::getDisplayLanguages怎么用?PHP Locale::getDisplayLanguages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Locale\Locale
的用法示例。
在下文中一共展示了Locale::getDisplayLanguages方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDisplayLanguage
/**
* Get language name
*
* @param string $code
* @return string
*/
public function getDisplayLanguage($code)
{
$languages = Locale::getDisplayLanguages($this->request->getLocale());
if (isset($languages[$code])) {
return $languages[$code];
}
}
示例2: saveSettings
/**
* @Route("/admin/settings/save/{formType}", name="cuteflow_admin_settings_save")
* @Template("CuteFlowCoreBundle:Admin:settings.html.twig")
*
* @param string $formType
* @return void
*/
public function saveSettings($formType)
{
$em = $this->getDoctrine()->getEntityManager();
$settings = $em->find('CuteFlowCoreBundle:Settings', 1);
if ($settings == null) {
$settings = new \CuteFlow\CoreBundle\Entity\Settings();
}
$localeNames = Locale::getDisplayLanguages($this->getRequest()->getSession()->getLocale());
$availableLanguages = array_intersect_key($localeNames, $this->container->getParameter('cuteflow.languages'));
$generalForm = $this->createForm(new SettingsGeneralType(), $settings);
$emailForm = $this->createForm(new SettingsEmailType(), $settings);
switch ($formType) {
case 'email':
$form = $emailForm;
break;
case 'general':
$form = $generalForm;
break;
}
$success = false;
$form->bindRequest($this->getRequest());
if ($form->isValid()) {
$em->persist($settings);
$em->flush();
$success = true;
}
return array('generalForm' => $generalForm->createView(), 'emailForm' => $emailForm->createView(), 'availableLanguages' => $availableLanguages, 'formType' => $formType, 'saveSuccess' => $success, 'form' => $form->createView());
}
示例3: language
/**
* @param $code
* @param null $locale
*
* @return string
*/
public function language($code, $locale = null)
{
$languages = Locale::getDisplayLanguages($locale ?: $this->localeDetector->getLocale());
if (array_key_exists($code, $languages)) {
return $this->fixCharset($languages[$code]);
}
return '';
}
示例4: testGetDisplayLanguagesReturnsFullListForSubLocale
public function testGetDisplayLanguagesReturnsFullListForSubLocale()
{
$this->skipIfIntlExtensionIsNotLoaded();
$languagesDe = Locale::getDisplayLanguages('de');
$languagesDeCh = Locale::getDisplayLanguages('de_CH');
$this->assertEquals(count($languagesDe), count($languagesDeCh));
$this->assertEquals($languagesDe['be'], 'Weißrussisch');
$this->assertEquals($languagesDeCh['be'], 'Weissrussisch');
}
示例5: configure
/**
* @inheritDoc
*/
protected function configure()
{
$this->addOption('choices', Locale::getDisplayLanguages($this->locale));
parent::configure();
}
示例6: testGetDisplayLanguages
public function testGetDisplayLanguages()
{
$languages = Locale::getDisplayLanguages('en');
$this->assertEquals('Brazilian Portuguese', $languages['pt_BR']);
}
示例7: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('choices' => Locale::getDisplayLanguages(\Locale::getDefault())));
}
示例8: getDefaultOptions
/**
* {@inheritdoc}
*/
public function getDefaultOptions(array $options)
{
return array('choices' => Locale::getDisplayLanguages(\Locale::getDefault()));
}
示例9: getCountryLanguages
/**
* {@inheritdoc}
*/
public function getCountryLanguages($language)
{
return $this->locale->getDisplayLanguages($language);
}
示例10: getDisplayLanguages
/**
* Returns the language names for locale
*
* @return array The language names with their codes as keys
*/
public function getDisplayLanguages()
{
return SymfonyLocale::getDisplayLanguages($this->getLocale());
}
示例11: getDefaultOptions
/**
* {@inheritdoc}
*/
public function getDefaultOptions(array $options)
{
return array('choices' => Locale::getDisplayLanguages(\Locale::getDefault()), 'value_strategy' => ChoiceList::COPY_CHOICE);
}