From acdece7005c933532420bdcdde4037fd88831608 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Fri, 26 Oct 2018 17:24:06 -0400 Subject: [PATCH] Deprecating support for legacy translations directory --- UPGRADE-4.2.md | 1 + UPGRADE-5.0.md | 1 + src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md | 1 + .../DependencyInjection/FrameworkExtension.php | 8 +++++++- .../Resources/translations/test_default.en.xlf | 0 .../DependencyInjection/FrameworkExtensionTest.php | 14 ++++++++++++++ 6 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/Resources/translations/test_default.en.xlf diff --git a/UPGRADE-4.2.md b/UPGRADE-4.2.md index c066fc8b9f07e..80ee9ac889917 100644 --- a/UPGRADE-4.2.md +++ b/UPGRADE-4.2.md @@ -155,6 +155,7 @@ FrameworkBundle * The `--no-debug` console option has been deprecated, set the "APP_DEBUG" environment variable to "0" instead. * The `Templating\Helper\TranslatorHelper::transChoice()` method has been deprecated, use the `trans()` one instead with a `%count%` parameter. + * Deprecated support for legacy translations directories `src/Resources/translations/` and `src/Resources//translations/`, use `translations/` instead. Messenger --------- diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index ade8f69f7c030..3d3914bf976c3 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -169,6 +169,7 @@ FrameworkBundle * The `--no-debug` console option has been removed, set the "APP_DEBUG" environment variable to "0" instead. * The `Templating\Helper\TranslatorHelper::transChoice()` method has been removed, use the `trans()` one instead with a `%count%` parameter. + * Removed support for legacy translations directories `src/Resources/translations/` and `src/Resources//translations/`, use `translations/` instead. HttpFoundation -------------- diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index 04f7dec53b5ad..26a969fe3cc85 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -24,6 +24,7 @@ CHANGELOG * Deprecated `CachePoolClearerPass`. Use `Symfony\Component\Cache\DependencyInjection\CachePoolClearerPass` instead. * Deprecated `CachePoolPass`. Use `Symfony\Component\Cache\DependencyInjection\CachePoolPass` instead. * Deprecated `CachePoolPrunerPass`. Use `Symfony\Component\Cache\DependencyInjection\CachePoolPrunerPass` instead. + * Deprecated support for legacy translations directories `src/Resources/translations/` and `src/Resources//translations/`, use `translations/` instead. 4.1.0 ----- diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index fd242bf8458d0..8430c0bbcbe5e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -1009,6 +1009,8 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder $dirs[] = $dir; } if ($container->fileExists($dir = $rootDir.sprintf('/Resources/%s/translations', $name))) { + @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED); + $dirs[] = $dir; } } @@ -1025,6 +1027,10 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder $dirs[] = $defaultDir; } if ($container->fileExists($dir = $rootDir.'/Resources/translations')) { + if ($dir !== $defaultDir) { + @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED); + } + $dirs[] = $dir; } @@ -1307,7 +1313,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder $annotationLoader = new Definition( 'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader', - array(new Reference('annotation_reader')) + array(new Reference('annotation_reader')) ); $annotationLoader->setPublic(false); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/Resources/translations/test_default.en.xlf b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/Resources/translations/test_default.en.xlf new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index bbe53dbf69403..f746196d732d8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -691,6 +691,20 @@ public function testTranslator() $this->assertEquals(array('fr'), $calls[1][1][0]); } + /** + * @group legacy + * @expectedDeprecation Translations directory "%s/Resources/translations" is deprecated since Symfony 4.2, use "%s/translations" instead. + */ + public function testLegacyTranslationsDirectory() + { + $container = $this->createContainerFromFile('full', array('kernel.root_dir' => __DIR__.'/Fixtures')); + $options = $container->getDefinition('translator.default')->getArgument(4); + $files = array_map('realpath', $options['resource_files']['en']); + + $dir = str_replace('/', \DIRECTORY_SEPARATOR, __DIR__.'/Fixtures/Resources/translations/test_default.en.xlf'); + $this->assertContains($dir, $files, '->registerTranslatorConfiguration() finds translation resources in legacy directory'); + } + public function testTranslatorMultipleFallbacks() { $container = $this->createContainerFromFile('translator_fallbacks');