Skip to content

Commit 064e369

Browse files
[Contracts] Add Translation\TranslatorInterface + decouple symfony/validator from symfony/translation
1 parent b1755cb commit 064e369

File tree

58 files changed

+1011
-203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1011
-203
lines changed

UPGRADE-4.2.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,15 @@ Serializer
149149

150150
* Relying on the default value (false) of the "as_collection" option is deprecated since 4.2.
151151
You should set it to false explicitly instead as true will be the default value in 5.0.
152+
153+
Translation
154+
-----------
155+
156+
* The `TranslatorInterface` has been deprecated in favor of `Symfony\Contracts\Translation\TranslatorInterface`
157+
* The `MessageSelector`, `Interval` and `PluralizationRules` classes have been deprecated, use `IdentityTranslator` instead
158+
159+
Validator
160+
---------
161+
162+
* The component is now decoupled from `symfony/translation` and uses `Symfony\Contracts\Translation\TranslatorInterface` instead
163+
* The `ValidatorBuilderInterface` has been deprecated and `ValidatorBuilder` made final

UPGRADE-5.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ Translation
146146

147147
* The `FileDumper::setBackup()` method has been removed.
148148
* The `TranslationWriter::disableBackup()` method has been removed.
149+
* The `TranslatorInterface` has been removed in favor of `Symfony\Contracts\Translation\TranslatorInterface`
150+
* The `MessageSelector`, `Interval` and `PluralizationRules` classes have been removed, use `IdentityTranslator` instead
149151

150152
TwigBundle
151153
----------
@@ -158,6 +160,8 @@ Validator
158160
* The `Email::__construct()` 'strict' property has been removed. Use 'mode'=>"strict" instead.
159161
* Calling `EmailValidator::__construct()` method with a boolean parameter has been removed, use `EmailValidator("strict")` instead.
160162
* Removed the `checkDNS` and `dnsMessage` options from the `Url` constraint.
163+
* The component is now decoupled from `symfony/translation` and uses `Symfony\Contracts\Translation\TranslatorInterface` instead
164+
* The `ValidatorBuilderInterface` has been removed and `ValidatorBuilder` is now final
161165

162166
Workflow
163167
--------

src/Symfony/Bridge/Twig/Extension/TranslationExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Bridge\Twig\TokenParser\TransChoiceTokenParser;
1717
use Symfony\Bridge\Twig\TokenParser\TransDefaultDomainTokenParser;
1818
use Symfony\Bridge\Twig\TokenParser\TransTokenParser;
19-
use Symfony\Component\Translation\TranslatorInterface;
19+
use Symfony\Contracts\Translation\TranslatorInterface;
2020
use Twig\Extension\AbstractExtension;
2121
use Twig\NodeVisitor\NodeVisitorInterface;
2222
use Twig\TokenParser\AbstractTokenParser;

src/Symfony/Bridge/Twig/Tests/Extension/Fixtures/StubTranslator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bridge\Twig\Tests\Extension\Fixtures;
1313

14-
use Symfony\Component\Translation\TranslatorInterface;
14+
use Symfony\Contracts\Translation\TranslatorInterface;
1515

1616
class StubTranslator implements TranslatorInterface
1717
{

src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Bridge\Twig\Extension\TranslationExtension;
1616
use Symfony\Bridge\Twig\Translation\TwigExtractor;
1717
use Symfony\Component\Translation\MessageCatalogue;
18+
use Symfony\Contracts\Translation\TranslatorInterface;
1819
use Twig\Environment;
1920
use Twig\Error\Error;
2021
use Twig\Loader\ArrayLoader;
@@ -33,7 +34,7 @@ public function testExtract($template, $messages)
3334
'cache' => false,
3435
'autoescape' => false,
3536
));
36-
$twig->addExtension(new TranslationExtension($this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock()));
37+
$twig->addExtension(new TranslationExtension($this->getMockBuilder(TranslatorInterface::class)->getMock()));
3738

3839
$extractor = new TwigExtractor($twig);
3940
$extractor->setPrefix('prefix');
@@ -82,7 +83,7 @@ public function getExtractData()
8283
public function testExtractSyntaxError($resources)
8384
{
8485
$twig = new Environment($this->getMockBuilder('Twig\Loader\LoaderInterface')->getMock());
85-
$twig->addExtension(new TranslationExtension($this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock()));
86+
$twig->addExtension(new TranslationExtension($this->getMockBuilder(TranslatorInterface::class)->getMock()));
8687

8788
$extractor = new TwigExtractor($twig);
8889

@@ -124,7 +125,7 @@ public function testExtractWithFiles($resource)
124125
'cache' => false,
125126
'autoescape' => false,
126127
));
127-
$twig->addExtension(new TranslationExtension($this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock()));
128+
$twig->addExtension(new TranslationExtension($this->getMockBuilder(TranslatorInterface::class)->getMock()));
128129

129130
$extractor = new TwigExtractor($twig);
130131
$catalogue = new MessageCatalogue('en');

src/Symfony/Bridge/Twig/composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"symfony/polyfill-intl-icu": "~1.0",
3030
"symfony/routing": "~3.4|~4.0",
3131
"symfony/templating": "~3.4|~4.0",
32-
"symfony/translation": "~3.4|~4.0",
32+
"symfony/translation": "~4.2",
3333
"symfony/yaml": "~3.4|~4.0",
3434
"symfony/security": "~3.4|~4.0",
3535
"symfony/security-acl": "~2.8|~3.0",
@@ -41,8 +41,9 @@
4141
"symfony/workflow": "~3.4|~4.0"
4242
},
4343
"conflict": {
44+
"symfony/console": "<3.4",
4445
"symfony/form": "<4.1.2",
45-
"symfony/console": "<3.4"
46+
"symfony/translation": "<4.2"
4647
},
4748
"suggest": {
4849
"symfony/finder": "",

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
1616
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
1717
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
18-
use Symfony\Component\Translation\TranslatorInterface;
18+
use Symfony\Contracts\Translation\TranslatorInterface;
1919

2020
/**
2121
* Generates the catalogues for translations.

src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
use Symfony\Component\Translation\MessageCatalogue;
2727
use Symfony\Component\Translation\Reader\TranslationReaderInterface;
2828
use Symfony\Component\Translation\Translator;
29-
use Symfony\Component\Translation\TranslatorInterface;
29+
use Symfony\Contracts\Translation\TranslatorInterface;
3030

3131
/**
3232
* Helps finding unused or missing translation messages in a given locale

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/LoggingTranslatorPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1717
use Symfony\Component\Translation\TranslatorBagInterface;
18-
use Symfony\Component\Translation\TranslatorInterface;
18+
use Symfony\Contracts\Translation\TranslatorInterface;
1919

2020
/**
2121
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>

src/Symfony/Bundle/FrameworkBundle/Resources/config/identity_translator.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
<services>
77
<defaults public="false" />
88

9-
<service id="translator" class="Symfony\Component\Translation\IdentityTranslator" public="true">
10-
<argument type="service" id="translator.selector" />
11-
</service>
9+
<service id="translator" class="Symfony\Component\Translation\IdentityTranslator" public="true" />
1210
<service id="Symfony\Component\Translation\TranslatorInterface" alias="translator" />
11+
<service id="Symfony\Contracts\Translation\TranslatorInterface" alias="translator" />
1312

14-
<service id="translator.selector" class="Symfony\Component\Translation\MessageSelector" />
13+
<service id="identity_translator" class="Symfony\Component\Translation\IdentityTranslator" />
14+
<service id="translator.selector" class="Symfony\Component\Translation\MessageSelector">
15+
<deprecated>The "%service_id%" service is deprecated since Symfony 4.2, use "identity_translator" instead.</deprecated>
16+
</service>
1517
</services>
1618
</container>

0 commit comments

Comments
 (0)