Я использую Symfony2 country Field Type, он работает хорошо, и названия стран переводятся. Я сохраняю двузначный код страны в столбце country
моей организации.
Как я могу отобразить полное, переведенное название страны?Вот как я добавил поле в форму:
$builder
->add('country', 'country', array(
'label' => 'Paese', 'preferred_choices' => array('IT')
));
И затем в моем контроллере:
$user = $this->getDoctrine()->getRepository('AcmeHelloBundle:User');
$countryCode = $user->getCountry();
$countryName = null; // Get translated country name from code
Или в моем шаблоне ветки:
{# Output the country code and name #}
{{ user.country }}
{# translated country name from code #}