Skip to content

Commit

Permalink
Translator component has default domain for null implemented
Browse files Browse the repository at this point in the history
no need to have default translation domain logic in 3 different places
  • Loading branch information
Tobion authored and fabpot committed Mar 26, 2015
1 parent d5673c2 commit ccd32d5
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
8 changes: 0 additions & 8 deletions src/Symfony/Bridge/Twig/Extension/TranslationExtension.php
Expand Up @@ -90,19 +90,11 @@ public function getTranslationNodeVisitor()

public function trans($message, array $arguments = array(), $domain = null, $locale = null)
{
if (null === $domain) {
$domain = 'messages';
}

return $this->translator->trans($message, $arguments, $domain, $locale);
}

public function transchoice($message, $count, array $arguments = array(), $domain = null, $locale = null)
{
if (null === $domain) {
$domain = 'messages';
}

return $this->translator->transChoice($message, $count, array_merge(array('%count%' => $count), $arguments), $domain, $locale);
}

Expand Down
6 changes: 1 addition & 5 deletions src/Symfony/Component/Form/Extension/Core/Type/BaseType.php
Expand Up @@ -56,7 +56,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
$uniqueBlockPrefix = '_'.$blockName;
}

if (!$translationDomain) {
if (null === $translationDomain) {
$translationDomain = $view->parent->vars['translation_domain'];
}
} else {
Expand All @@ -76,10 +76,6 @@ public function buildView(FormView $view, FormInterface $form, array $options)
}
$blockPrefixes[] = $uniqueBlockPrefix;

if (!$translationDomain) {
$translationDomain = 'messages';
}

$view->vars = array_replace($view->vars, array(
'form' => $view,
'id' => $id,
Expand Down
Expand Up @@ -112,7 +112,7 @@ public function testDefaultTranslationDomain()
->getForm()
->createView();

$this->assertEquals('messages', $view['child']->vars['translation_domain']);
$this->assertNull($view['child']->vars['translation_domain']);
}

public function testPassLabelToView()
Expand Down

0 comments on commit ccd32d5

Please sign in to comment.