rohitrounak
rohitrounak

Reputation: 55

symfony 2.3 : how to translation dropdown text

Is there a way through which I can translate the contents of the choice type (drop down). the value of the content will be the same but the text in option should be translated.

Upvotes: 2

Views: 339

Answers (1)

sf_tristanb
sf_tristanb

Reputation: 8855

Just add the keys into your translation file.

Example if your choices are

array(
    1 => "my.choice.1",
    2 => "my.choice.2"
);

Just add

  <trans-unit id="">
    <source>my.choice.1</source>
    <target>Pizza</target>
  </trans-unit>

Symfony will automatically pass options inside the choice type inside the translator service.

Upvotes: 1

Related Questions