symfony/symfony — pull request #8837 by bschussek (2013-08-23 15:29:28+00:00)
Title: [Translation] Fixed regression: When only one rule is passed to transChoice(), this rule should be used

| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -

There was one regression introduced by #8789, namely when only one message is passed to `transChoice()`. Before, the following code was perfectly valid:

```
$translator = new IdentityTranslator(new MessageSelector());

echo $translator->transChoice('There are two apples', 2, array('%count%' => 2));
```

This didn't fail, because internally, the locale `null` was passed to `MessageSelector`, which always returned the index `0` in that case.

Now, the user's locale is passed, and if the selector returns anything but `0`, an exception is thrown.

I removed this exception for the case that exactly one standard message (without explicit interval) was passed. In that case, this message is returned (just like in `trans()`). See the tests for clarification.