10000 [FrameworkBundle] Deprecating support for legacy translations directory by yceruto · Pull Request #28997 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Deprecating support for legacy translations directory #28997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADE-4.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------
Expand Down
1 change: 1 addition & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
0