Deprecating support for legacy translations directory

This commit is contained in:
Yonel Ceruto 2018-10-26 17:24:06 -04:00
parent 031762e191
commit acdece7005
6 changed files with 24 additions and 1 deletions

View File

@ -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/<BundleName>/translations/`, use `translations/` instead.
Messenger
---------

View File

@ -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/<BundleName>/translations/`, use `translations/` instead.
HttpFoundation
--------------

View File

@ -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/<BundleName>/translations/`, use `translations/` instead.
4.1.0
-----

View File

@ -1009,6 +1009,8 @@ class FrameworkExtension extends Extension
$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 @@ class FrameworkExtension extends Extension
$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 @@ class FrameworkExtension extends Extension
$annotationLoader = new Definition(
'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
array(new Reference('annotation_reader'))
array(new Reference('annotation_reader'))
);
$annotationLoader->setPublic(false);

View File

@ -691,6 +691,20 @@ abstract class FrameworkExtensionTest extends TestCase
$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');