8000 feature #28997 [FrameworkBundle] Deprecating support for legacy trans… · symfony/symfony@c333d85 · GitHub
[go: up one dir, main page]

Skip to content

Commit c333d85

Browse files
committed
feature #28997 [FrameworkBundle] Deprecating support for legacy translations directory (yceruto)
This PR was merged into the 4.2-dev branch. Discussion ---------- [FrameworkBundle] Deprecating support for legacy translations directory | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #28810 (comment) | License | MIT | Doc PR | TODO Commits ------- acdece7 Deprecating support for legacy translations directory
2 parents 031762e + acdece7 commit c333d85

File tree

6 files changed

+24
-1
lines changed

6 files changed

+24
-1
lines changed

UPGRADE-4.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ FrameworkBundle
155155
* The `--no-debug` console option has been deprecated,
156156
set the "APP_DEBUG" environment variable to "0" instead.
157157
* The `Templating\Helper\TranslatorHelper::transChoice()` method has been deprecated, use the `trans()` one instead with a `%count%` parameter.
158+
* Deprecated support for legacy translations directories `src/Resources/translations/` and `src/Resources/<BundleName>/translations/`, use `translations/` instead.
158159

159160
Messenger
160161
---------

UPGRADE-5.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ FrameworkBundle
169169
* The `--no-debug` console option has been removed,
170170
set the "APP_DEBUG" environment variable to "0" instead.
171171
* The `Templating\Helper\TranslatorHelper::transChoice()` method has been removed, use the `trans()` one instead with a `%count%` parameter.
172+
* Removed support for legacy translations directories `src/Resources/translations/` and `src/Resources/<BundleName>/translations/`, use `translations/` instead.
172173

173174
HttpFoundation
174175
--------------

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ CHANGELOG
2424
* Deprecated `CachePoolClearerPass`. Use `Symfony\Component\Cache\ 8000 DependencyInjection\CachePoolClearerPass` instead.
2525
* Deprecated `CachePoolPass`. Use `Symfony\Component\Cache\DependencyInjection\CachePoolPass` instead.
2626
* Deprecated `CachePoolPrunerPass`. Use `Symfony\Component\Cache\DependencyInjection\CachePoolPrunerPass` instead.
27+
* Deprecated support for legacy translations directories `src/Resources/translations/` and `src/Resources/<BundleName>/translations/`, use `translations/` instead.
2728

2829
4.1.0
2930
-----

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,8 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
10091009
$dirs[] = $dir;
10101010
}
10111011
if ($container->fileExists($dir = $rootDir.sprintf('/Resources/%s/translations', $name))) {
1012+
@trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED);
1013+
10121014
$dirs[] = $dir;
10131015
}
10141016
}
@@ -1025,6 +1027,10 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
10251027
$dirs[] = $defaultDir;
10261028
}
10271029
if ($container->fileExists($dir = $rootDir.'/Resources/translations')) {
1030+
if ($dir !== $defaultDir) {
1031+
@trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED);
1032+
}
1033+
10281034
$dirs[] = $dir;
10291035
}
10301036

@@ -1307,7 +1313,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
13071313

13081314
$annotationLoader = new Definition(
13091315
'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
1310-
array(new Reference('annotation_reader'))
1316+
array(new Reference('annotation_reader'))
13111317
);
13121318
$annotationLoader->setPublic(false);
13131319

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/Resources/translations/test_default.en.xlf

Whitespace-only changes.

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,20 @@ public function testTranslator()
691691
$this->assertEquals(array('fr'), $calls[1][1][0]);
692692
}
693693

694+
/**
695+
* @group legacy
696+
* @expectedDeprecation Translations directory "%s/Resources/translations" is deprecated since Symfony 4.2, use "%s/translations" instead.
697+
*/
698+
public function testLegacyTranslationsDirectory()
699+
{
700+
$container = $this->createContainerFromFile('full', array('kernel.root_dir' => __DIR__.'/Fixtures'));
701+
$options = $container->getDefinition('translator.default')->getArgument(4);
702+
$files = array_map('realpath', $options['resource_files']['en']);
703+
704+
$dir = str_replace('/', \DIRECTORY_SEPARATOR, __DIR__.'/Fixtures/Resources/translations/test_default.en.xlf');
705+
$this->assertContains($dir, $files, '->registerTranslatorConfiguration() finds translation resources in legacy directory');
706+
}
707+
694708
public function testTranslatorMultipleFallbacks()
695709
{
696710
$container = $this->createContainerFromFile('translator_fallbacks');

0 commit comments

Comments
 (0)
0