[Form] Implemented LanguageField
This commit is contained in:
parent
9db7db4439
commit
93d3716a84
60
src/Symfony/Component/Form/LanguageField.php
Normal file
60
src/Symfony/Component/Form/LanguageField.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Form;
|
||||
|
||||
/**
|
||||
* A field for selecting from a list of languages
|
||||
*
|
||||
* @author Bernhard Schussek <bernhard.schussek@symfony-project.com>
|
||||
*/
|
||||
class LanguageField extends ChoiceField
|
||||
{
|
||||
/**
|
||||
* Caches the language choices in different locales
|
||||
* @var array
|
||||
*/
|
||||
protected static $languages;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->addOption('choices', self::getLanguageChoices($this->locale));
|
||||
|
||||
parent::configure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of languages for a locale
|
||||
*
|
||||
* @param string $locale The locale to use for the language names
|
||||
* @throws RuntimeException When the resource bundles cannot be loaded
|
||||
*/
|
||||
protected static function getLanguageChoices($locale)
|
||||
{
|
||||
if (!isset(self::$languages[$locale])) {
|
||||
$bundle = new \ResourceBundle($locale, __DIR__.'/Resources/data/lang');
|
||||
|
||||
if ($bundle === null) {
|
||||
throw new RuntimeException('The language resource bundle could not be loaded');
|
||||
}
|
||||
|
||||
$collator = new \Collator($locale);
|
||||
$languages = array();
|
||||
|
||||
foreach ($bundle->get('Languages') as $code => $name) {
|
||||
// "mul" is the code for multiple languages
|
||||
if ($code !== 'mul') {
|
||||
$languages[$code] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
$collator->asort($languages);
|
||||
|
||||
self::$languages[$locale] = $languages;
|
||||
}
|
||||
|
||||
return self::$languages[$locale];
|
||||
}
|
||||
}
|
BIN
src/Symfony/Component/Form/Resources/data/lang/af.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/af.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ak.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ak.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/am.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/am.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ar.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ar.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/as.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/as.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/asa.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/asa.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/az.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/az.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/az_AZ.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/az_AZ.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/az_Cyrl.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/az_Cyrl.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/az_Latn.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/az_Latn.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/az_Latn_AZ.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/az_Latn_AZ.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/be.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/be.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/bem.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/bem.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/bez.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/bez.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/bg.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/bg.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/bm.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/bm.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/bn.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/bn.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/bn_IN.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/bn_IN.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/bo.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/bo.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/bs.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/bs.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ca.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ca.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/cgg.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/cgg.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/chr.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/chr.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/cs.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/cs.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/cy.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/cy.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/da.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/da.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/dav.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/dav.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/de.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/de.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/de_CH.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/de_CH.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ebu.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ebu.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ee.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ee.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/el.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/el.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/en.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/en.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/en_RH.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/en_RH.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/en_ZW.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/en_ZW.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/eo.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/eo.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/es.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/es.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/es_AR.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/es_AR.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/es_CL.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/es_CL.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/et.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/et.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/eu.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/eu.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/fa.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/fa.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/fa_AF.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/fa_AF.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ff.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ff.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/fi.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/fi.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/fil.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/fil.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/fil_PH.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/fil_PH.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/fo.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/fo.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/fr.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/fr.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ga.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ga.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/gl.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/gl.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/gsw.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/gsw.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/gu.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/gu.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/guz.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/guz.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/gv.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/gv.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ha.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ha.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ha_GH.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ha_GH.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ha_Latn.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ha_Latn.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ha_Latn_GH.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ha_Latn_GH.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ha_Latn_NE.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ha_Latn_NE.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ha_Latn_NG.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ha_Latn_NG.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ha_NE.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ha_NE.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ha_NG.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ha_NG.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/haw.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/haw.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/he.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/he.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/he_IL.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/he_IL.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/hi.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/hi.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/hr.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/hr.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/hu.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/hu.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/hy.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/hy.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/id.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/id.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/id_ID.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/id_ID.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ig.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ig.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ii.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ii.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/in.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/in.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/in_ID.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/in_ID.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/is.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/is.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/it.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/it.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/iw.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/iw.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/iw_IL.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/iw_IL.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ja.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ja.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ja_JP.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ja_JP.res
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/jmc.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/jmc.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ka.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ka.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/kab.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/kab.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/kam.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/kam.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/kde.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/kde.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/kea.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/kea.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/khq.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/khq.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/ki.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/ki.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/kk.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/kk.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/kk_Cyrl.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/kk_Cyrl.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/kk_Cyrl_KZ.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/kk_Cyrl_KZ.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/kk_KZ.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/kk_KZ.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/kl.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/kl.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/kln.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/kln.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/km.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/km.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Form/Resources/data/lang/kn.res
Normal file
BIN
src/Symfony/Component/Form/Resources/data/lang/kn.res
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user