Skip to content

Commit 9d687a1

Browse files
committed
Use FallbackFormatter instead of support for multiple formatters
1 parent 4b94270 commit 9d687a1

File tree

5 files changed

+7
-28
lines changed

5 files changed

+7
-28
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ CHANGELOG
1111
* Deprecated the `Symfony\Bundle\FrameworkBundle\Controller\Controller` class in favor of `Symfony\Bundle\FrameworkBundle\Controller\AbstractController`.
1212
* Enabled autoconfiguration for `Psr\Log\LoggerAwareInterface`
1313
* Added new "auto" mode for `framework.session.cookie_secure` to turn it on when HTTPS is used
14-
* Added support for configuring the `Translator` with multiple formatters.
1514

1615
4.1.0
1716
-----

DependencyInjection/Configuration.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -690,27 +690,14 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode)
690690
->{!class_exists(FullStack::class) && class_exists(Translator::class) ? 'canBeDisabled' : 'canBeEnabled'}()
691691
->fixXmlConfig('fallback')
692692
->fixXmlConfig('path')
693-
->fixXmlConfig('domain_formatter')
694693
->children()
695694
->arrayNode('fallbacks')
696695
->beforeNormalization()->ifString()->then(function ($v) { return array($v); })->end()
697696
->prototype('scalar')->end()
698697
->defaultValue(array('en'))
699698
->end()
700699
->booleanNode('logging')->defaultValue(false)->end()
701-
->scalarNode('formatter')
702-
->info('The default formatter to use if none is specified.')
703-
->defaultValue('translator.formatter.default')
704-
->end()
705-
->arrayNode('domain_formatters')
706-
->info('Configure different formatters per domain.')
707-
->useAttributeAsKey('domain')
708-
->prototype('array')
709-
->children()
710-
->scalarNode('service')->cannotBeEmpty()->end()
711-
->end()
712-
->end()
713-
->end()
700+
->scalarNode('formatter')->defaultValue('translator.formatter.default')->end()
714701
->scalarNode('default_path')
715702
->info('The default path used to load translations')
716703
->defaultValue('%kernel.project_dir%/translations')

DependencyInjection/FrameworkExtension.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,6 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
981981
$container->setAlias('translator.formatter', new Alias($config['formatter'], false));
982982
$translator = $container->findDefinition('translator.default');
983983
$translator->addMethodCall('setFallbackLocales', array($config['fallbacks']));
984-
foreach ($config['domain_formatters'] as $formatter) {
985-
$translator->addMethodCall('addFormatter', array($formatter['domain'], new Reference($formatter['service'])));
986-
}
987984

988985
$container->setParameter('translator.logging', $config['logging']);
989986
$container->setParameter('translator.default_path', $config['default_path']);

Resources/config/schema/symfony-1.0.xsd

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,19 +185,13 @@
185185
<xsd:sequence>
186186
<xsd:element name="fallback" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
187187
<xsd:element name="path" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
188-
<xsd:element name="domain-formatter" type="translator_formatter" minOccurs="0" maxOccurs="unbounded" />
189188
</xsd:sequence>
190189
<xsd:attribute name="enabled" type="xsd:boolean" />
191190
<xsd:attribute name="fallback" type="xsd:string" />
192191
<xsd:attribute name="logging" type="xsd:boolean" />
193192
<xsd:attribute name="formatter" type="xsd:string" />
194193
</xsd:complexType>
195194

196-
<xsd:complexType name="translator_formatter">
197-
<xsd:attribute name="domain" type="xsd:string" use="required" />
198-
<xsd:attribute name="service" type="xsd:string" />
199-
</xsd:complexType>
200-
201195
<xsd:complexType name="validation">
202196
<xsd:choice minOccurs="0" maxOccurs="unbounded">
203197
<xsd:element name="static-method" type="xsd:string" />

Resources/config/translation.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@
2929
<tag name="monolog.logger" channel="translation" />
3030
</service>
3131

32-
<service id="translator.formatter.default" class="Symfony\Component\Translation\Formatter\MessageFormatter">
32+
<service id="translator.formatter.symfony" class="Symfony\Component\Translation\Formatter\MessageFormatter">
3333
<argument type="service" id="identity_translator" />
3434
</service>
35-
3635
<service id="translator.formatter.intl" class="Symfony\Component\Translation\Formatter\IntlMessageFormatter" public="false" />
37-
38-
<service id="translator.selector" class="Symfony\Component\Translation\MessageSelector" public="false" />
36+
<service id="translator.formatter.fallback" class="Symfony\Component\Translation\Formatter\FallbackFormatter" public="false">
37+
<argument type="service" id="translator.formatter.intl" />
38+
<argument type="service" id="translator.formatter.symfony" />
39+
</service>
40+
<service id="translator.formatter.default" alias="translator.formatter.fallback" />
3941

4042
<service id="translation.loader.php" class="Symfony\Component\Translation\Loader\PhpFileLoader">
4143
<tag name="translation.loader" alias="php" />

0 commit comments

Comments
 (0)