Skip to content

Commit

Permalink
bug #1904 [Translator] Fix changing dump directory using AssetMapper …
Browse files Browse the repository at this point in the history
…(maelanleborgne)

This PR was merged into the 2.x branch.

Discussion
----------

[Translator] Fix changing dump directory using AssetMapper

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| Issues        | Fix #1642
| License       | MIT

The configuration node `ux_translator.dump_directory` wasn't correctly taken into account when using UxTranslator with AssetMapper.
This PR fixes the configuration prepend of AssetMapper to use the custom path + adds a "caution" section in the docs to remind developers to also update their `importmap.php`.

Commits
-------

a27cfc8 Fix changing dump directory using AssetMapper
  • Loading branch information
kbond committed Jun 11, 2024
2 parents 4ca6f2f + a27cfc8 commit fc8de45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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',
],
],
]);
Expand Down

0 comments on commit fc8de45

Please sign in to comment.