merged branch bschussek/fix-translator (PR #7915)

This PR was merged into the master branch.

Discussion
----------

[Translation] Made translation domain defaults in Translator consistent with TranslatorInterface

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

Commits
-------

90a20d7 [Translation] Made translation domain defaults in Translator consistent with TranslatorInterface
This commit is contained in:
Fabien Potencier 2013-05-03 09:03:49 +02:00
commit 2d9154f467

View File

@ -90,8 +90,12 @@ class Translator implements TranslatorInterface
*
* @api
*/
public function addResource($format, $resource, $locale, $domain = 'messages')
public function addResource($format, $resource, $locale, $domain = null)
{
if (null === $domain) {
$domain = 'messages';
}
$this->resources[$locale][] = array($format, $resource, $domain);
if(in_array($locale, $this->fallbackLocales)) {
@ -167,12 +171,16 @@ class Translator implements TranslatorInterface
*
* @api
*/
public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null)
public function trans($id, array $parameters = array(), $domain = null, $locale = null)
{
if (null === $locale) {
$locale = $this->getLocale();
}
if (null === $domain) {
$domain = 'messages';
}
if (!isset($this->catalogues[$locale])) {
$this->loadCatalogue($locale);
}
@ -185,12 +193,16 @@ class Translator implements TranslatorInterface
*
* @api
*/
public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null)
public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null)
{
if (null === $locale) {
$locale = $this->getLocale();
}
if (null === $domain) {
$domain = 'messages';
}
if (!isset($this->catalogues[$locale])) {
$this->loadCatalogue($locale);
}