You can use athletic variables as described in the Ryan Weaver answer here . This function is a variation, but will work in your case since you use the locale variable as a variable.
The answer is that by default only two variables work (locale and env, and their values ββare pre-configured in Symfony: https://github.com/symfony/AsseticBundle/blob/master/DefaultValueSupplier.php#L31 .
config_dev.yml
assetic: use_controller: false
config.yml
You will also need to set your assetic.variables.locale [...] to the common possible combinations of your variable:
assetic: variables: locale: [en,fr,de]
... then use them inside the javaScripts tag after calling assetic:dump .
template
{% javascripts 'bundles/my/components/{locale}.js' %}
source share