Skip to content

Symfony/Locale getDisplayCountries for de_CH got only a few countries #5314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dominikzogg opened this issue Aug 22, 2012 · 8 comments
Closed
Labels

Comments

@dominikzogg
Copy link
Contributor

Hello

It seems, there is a bug in file symfony/src/Symfony/Component/Locale/Resources/data/region/de_CH.res, there are only a few countries (aprox 10-12).

Regards dominik

@fabpot
Copy link
Member

fabpot commented Aug 22, 2012

ping @eriksencosta

@ghost
Copy link

ghost commented Aug 22, 2012

Guys, I'll check it later today. I need to look at the ICU data source files.

@ghost
Copy link

ghost commented Aug 28, 2012

The ICU data repository have a lot of countries for the de locale and only a few for the de_CH locale. What happens is that the de_CH locale data file has only the countries were the spelling differs.

http://source.icu-project.org/repos/icu/icu/tags/release-49-1-2/source/data/region/de.txt
http://source.icu-project.org/repos/icu/icu/tags/release-49-1-2/source/data/region/de_CH.txt

@ghost
Copy link

ghost commented Aug 28, 2012

Wait... @dominikzogg can you plase provide a code snippet with your problem?

The Locale class merges the data for a locale with its fallback locale (i.e., merges the data for de_CH with the de locale), so this issue does not make sense. Take a look at Symfony\Component\Locale\Tests\LocaleTest. The assertions that check the count of countries, languages and locales shows that the code is working as expected.

@dominikzogg
Copy link
Contributor Author

@eriksencosta

Well i've done a new test:

get symfony:

php composer.phar create-project symfony/framework-standard-edition symfony

created a test bundle:

php app/console generate:bundle

creted an entity:

<?php

namespace Ibrows\TestBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Ibrows\TestBundle\Entity\Test
 *
 * @ORM\Table()
 * @ORM\Entity
 */
class Test
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string $country
     *
     * @ORM\Column(name="country", type="string", length=2)
     */
    private $country;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set country
     *
     * @param string $country
     * @return Test
     */
    public function setCountry($country)
    {
        $this->country = $country;

        return $this;
    }

    /**
     * Get country
     *
     * @return string 
     */
    public function getCountry()
    {
        return $this->country;
    }
}

created a form type:

<?php

namespace Ibrows\TestBundle\Form;

use Ibrows\TestBundle\Entity\Test;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class TestType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('country', 'country')
        ;
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Ibrows\\TestBundle\\Entity\\Test',
        ));
    }

    public function getName()
    {
        return 'test';
    }
}

controller:

<?php

namespace Ibrows\TestBundle\Controller;

use Ibrows\TestBundle\Entity\Test;
use Ibrows\TestBundle\Form\TestType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

class TestController extends Controller
{
    /**
     * @Route("/")
     * @Template()
     */
    public function indexAction()
    {
        // create new test entity
        $objTestEntity = new Test();

        // create new test form
        $objTestForm = $this->createForm(new TestType(), $objTestEntity);

        // return array
        return array
        (
            'testform' => $objTestForm->createView()
        );
    }
}

template:

{{ form_widget(testform) }}

with locale en or de i get the full list, with locale de_CH i get only this (php54, intl extension installed):

<div id="test">
    <div>
        <label for="test_country" class="required">Country</label>
        <select id="test_country" name="test[country]" required="required">
            <option value="QO">Äusseres Ozeanien</option>
            <option value="BD">Bangladesh</option>
            <option value="BW">Botswana</option>
            <option value="BN">Brunei</option>
            <option value="DJ">Djibouti</option>
            <option value="GB">Grossbritannien</option>
            <option value="CV">Kapverden</option>
            <option value="MH">Marshall-Inseln</option>
            <option value="RW">Rwanda</option>
            <option value="SB">Salomon-Inseln</option>
            <option value="ST">Sao Tomé und Principe</option>
            <option value="BY">Weissrussland</option>
            <option value="ZW">Zimbabwe</option>
        </select>
    </div>
    <input type="hidden" id="test__token" name="test[_token]" value="33748ea4007e59067dad42121d20c2e6d27214d6"/>
</div>

@ghost
Copy link

ghost commented Aug 28, 2012

Thanks @dominikzogg. I'll try to reproduce it using the code you provided.

@ghost
Copy link

ghost commented Oct 8, 2012

The PR #5641 fixes this bug.

@dominikzogg
Copy link
Contributor Author

@eriksencosta thx, will test it and close this issue.

fabpot added a commit that referenced this issue Dec 27, 2013
This PR was squashed before being merged into the 2.5-dev branch (closes #8423).

Discussion
----------

Update LocaleTest.php

de_CH locales does not fallback to de
see #5314

Commits
-------

572126b Update LocaleTest.php
fabpot added a commit to symfony/locale that referenced this issue Dec 27, 2013
This PR was squashed before being merged into the 2.5-dev branch (closes #8423).

Discussion
----------

Update LocaleTest.php

de_CH locales does not fallback to de
see symfony/symfony#5314

Commits
-------

572126b Update LocaleTest.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants