Skip to content

[Translator] Fix changing dump directory using AssetMapper #1904

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
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
6 changes: 6 additions & 0 deletions src/Translator/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ file. 2 of the new items are::
'path' => 'var/translations/configuration.js',
],

.. caution::

If you change the ``dump_directory`` in your configuration file, you will need to
replace the default ``var/translations/***`` with your new path in the
``importmap.php`` file.

These are then imported in your ``assets/translator.js`` file. This setup is
very similar to working with WebpackEncore. However, the ``var/translations/index.js``
file contains *every* translation in your app, which is not ideal for production
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public function prepend(ContainerBuilder $container)
if (!$this->isAssetMapperAvailable($container)) {
return;
}

$config = $container->getExtensionConfig('ux_translator')[0];
$container->prependExtensionConfig('framework', [
'asset_mapper' => [
'paths' => [
__DIR__.'/../../assets/dist' => '@symfony/ux-translator',
'%kernel.project_dir%/var/translations' => 'var/translations',
$config['dump_directory'] => '@app/translations',
Copy link
Member

@smnandre smnandre Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a functionnal test for this ? That will prevent any future regression

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to test for this. I don't think I can access the config, and I can't functionally test this without requiring asset mapper in require-dev, which is not wanted. If you have any input on how I can retrieve the config from the test scope I'd be glad to hear about it :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shouldn't have ignored this conversation 😭

],
],
]);
Expand Down