1
votes

I have a bit of a problem with internationalization in Symfony 1.4. For example let's say we have a word 'mois' which in French language means 'month' and also 'months'. So when I'm using i18n extract, I'm getting back only one option - mois, but I need to translate it either 'month' or 'months' depending on a situation. How can I get xml with two options?

I know about format_number_choice method, which gives me a good possibility to work with translations depending on value, but is there maybe some better way to extract that data without using this method?

1

1 Answers

0
votes

format_number_choice is your best option. It was created exactly for this purpose: dealing with translating plural words. To get XML with two options, you would use the function as follows:

format_number_choice('[1]%1% mois|(1,12]%1% mois', array('%1%' => $monthCount), $monthCount)

And your XML would look like:

<trans-unit id="3">
  <source>[1]%1% mois|(1,12]%1% mois</source>
  <target>[1]%1% month|(1,12]%1% months</target>
</trans-unit>

This is the best way to extract the data you need in Symfony 1.4.