[Form][Locale] Implemented LocaleField and added script for updating ICU data
This commit is contained in:
parent
d8b8ae0608
commit
b9c2e98315
23
src/Symfony/Component/Form/LocaleField.php
Normal file
23
src/Symfony/Component/Form/LocaleField.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Form;
|
||||
|
||||
use Symfony\Component\Locale\Locale;
|
||||
|
||||
/**
|
||||
* A field for selecting from a list of locales
|
||||
*
|
||||
* @author Bernhard Schussek <bernhard.schussek@symfony-project.com>
|
||||
*/
|
||||
class LocaleField extends ChoiceField
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->addOption('choices', Locale::getDisplayLocales($this->locale));
|
||||
|
||||
parent::configure();
|
||||
}
|
||||
}
|
@ -25,6 +25,12 @@ class Locale extends \Locale
|
||||
*/
|
||||
protected static $languages = array();
|
||||
|
||||
/**
|
||||
* Caches the different locales
|
||||
* @var array
|
||||
*/
|
||||
protected static $locales = array();
|
||||
|
||||
/**
|
||||
* Returns the country names for a locale
|
||||
*
|
||||
@ -116,4 +122,46 @@ class Locale extends \Locale
|
||||
{
|
||||
return array_keys(self::getDisplayLanguages(self::getDefault()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the locale names for a locale
|
||||
*
|
||||
* @param string $locale The locale to use for the locale names
|
||||
* @return array The locale names with their codes as keys
|
||||
* @throws RuntimeException When the resource bundles cannot be loaded
|
||||
*/
|
||||
public static function getDisplayLocales($locale)
|
||||
{
|
||||
if (!isset(self::$locales[$locale])) {
|
||||
$bundle = new \ResourceBundle($locale, __DIR__.'/Resources/data/names');
|
||||
|
||||
if (null === $bundle) {
|
||||
throw new \RuntimeException('The locale resource bundle could not be loaded');
|
||||
}
|
||||
|
||||
$collator = new \Collator($locale);
|
||||
$locales = array();
|
||||
|
||||
foreach ($bundle->get('Locales') as $code => $name) {
|
||||
$locales[$code] = $name;
|
||||
}
|
||||
|
||||
$collator->asort($locales);
|
||||
|
||||
self::$locales[$locale] = $locales;
|
||||
}
|
||||
|
||||
return self::$locales[$locale];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all available locale codes
|
||||
*
|
||||
* @return array The locale codes
|
||||
* @throws RuntimeException When the resource bundles cannot be loaded
|
||||
*/
|
||||
public static function getLocales()
|
||||
{
|
||||
return array_keys(self::getDisplayLocales(self::getDefault()));
|
||||
}
|
||||
}
|
@ -5,13 +5,9 @@ How to update the ICU data
|
||||
|
||||
$ svn co http://source.icu-project.org/repos/icu/icu/trunk/source/data icu-data
|
||||
|
||||
2. Build the region resource bundles
|
||||
2. Execute the build script
|
||||
|
||||
$ cd icu-data/region
|
||||
$ mkdir build
|
||||
$ genrb -d build *.txt
|
||||
|
||||
3a. Replace the *.res files bundled with Symfony2 with the new ones.
|
||||
$ php update-data.php /path/to/icu-data
|
||||
|
||||
.dat-package
|
||||
------------
|
||||
|
BIN
src/Symfony/Component/Locale/Resources/data/locales/af.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/af.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/af_NA.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/af_NA.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/af_ZA.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/af_ZA.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ak.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ak.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ak_GH.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ak_GH.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/am.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/am.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/am_ET.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/am_ET.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_AE.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_AE.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_BH.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_BH.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_DZ.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_DZ.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_EG.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_EG.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_IQ.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_IQ.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_JO.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_JO.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_KW.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_KW.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_LB.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_LB.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_LY.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_LY.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_MA.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_MA.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_OM.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_OM.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_QA.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_QA.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_SA.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_SA.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_SD.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_SD.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_SY.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_SY.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_TN.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_TN.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_YE.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ar_YE.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/as.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/as.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/as_IN.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/as_IN.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/asa.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/asa.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/asa_TZ.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/asa_TZ.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/az.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/az.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/az_AZ.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/az_AZ.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/az_Cyrl.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/az_Cyrl.res
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/az_Latn.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/az_Latn.res
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/be.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/be.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/be_BY.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/be_BY.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bem.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bem.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bem_ZM.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bem_ZM.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bez.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bez.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bez_TZ.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bez_TZ.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bg.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bg.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bg_BG.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bg_BG.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bm.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bm.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bm_ML.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bm_ML.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bn.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bn.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bn_BD.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bn_BD.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bn_IN.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bn_IN.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bo.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bo.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bo_CN.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bo_CN.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bo_IN.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bo_IN.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bs.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bs.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/bs_BA.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/bs_BA.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ca.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ca.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ca_ES.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ca_ES.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/cgg.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/cgg.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/cgg_UG.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/cgg_UG.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/chr.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/chr.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/chr_US.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/chr_US.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/cs.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/cs.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/cs_CZ.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/cs_CZ.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/cy.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/cy.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/cy_GB.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/cy_GB.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/da.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/da.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/da_DK.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/da_DK.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/dav.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/dav.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/dav_KE.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/dav_KE.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/de.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/de.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/de_AT.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/de_AT.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/de_BE.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/de_BE.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/de_CH.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/de_CH.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/de_DE.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/de_DE.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/de_LI.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/de_LI.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/de_LU.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/de_LU.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ebu.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ebu.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ebu_KE.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ebu_KE.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ee.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ee.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ee_GH.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ee_GH.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/ee_TG.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/ee_TG.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/el.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/el.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/el_CY.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/el_CY.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/el_GR.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/el_GR.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_AS.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_AS.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_AU.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_AU.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_BE.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_BE.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_BW.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_BW.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_BZ.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_BZ.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_CA.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_CA.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_GB.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_GB.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_GU.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_GU.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_HK.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_HK.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_IE.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_IE.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_IN.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_IN.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_JM.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_JM.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_MH.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_MH.res
Normal file
Binary file not shown.
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_MP.res
Normal file
BIN
src/Symfony/Component/Locale/Resources/data/locales/en_MP.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