基于语言环境的 Symfony assetic 多个输出文件
Symfony assetic multiple output files based in locale
我正在使用 symfony assetic 来管理 javascript 和 css 资产(缩小并合并到 1 个文件)
{% javascripts
'@CmsBundle/Resources/public/js/translations/en.js'
'@TempBundle/Resources/public/js/jquery.js'
'@AppBundle/Resources/public/js/functions.js'
filter='?uglifyjs2'
output='@HomeBundle/Resources/public/js/all.min.js'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
此代码运行良好,在目录中输出 1 个文件:
@HomeBundle/Resources/public/js/all.min.js
我想根据请求的语言环境添加更多javascript 翻译文件
@CmsBundle/Resources/public/js/translations/en.js
@CmsBundle/Resources/public/js/translations/de.js
@CmsBundle/Resources/public/js/translations/fr.js
具有基于输入语言环境的内容的预期输出文件:
@HomeBundle/Resources/public/js/all_en.min.js
@HomeBundle/Resources/public/js/all_de.min.js
@HomeBundle/Resources/public/js/all_fr.min.js
我尝试使用变量生成本地化文件,其内容基于输入语言环境文件:
{% javascripts
'@CmsBundle/Resources/public/js/translations/*'
'@TempBundle/Resources/public/js/jquery.js'
'@AppBundle/Resources/public/js/functions.js'
filter='?uglifyjs2'
output='@HomeBundle/Resources/public/js/all_{locale}.min.js'
vars= ['locale']
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
配置资产:
assetic:
variables:
locale: [ en,de,fr ]
生成了 3 个语言环境文件,但内容相同,并合并了 3 个输出文件中的所有语言环境文件。
我希望文件 all_en.min.js
仅包含 en.js
和其他非语言环境 javascript 文件的内容
改变
@CmsBundle/Resources/public/js/translations/*
至
@CmsBundle/Resources/public/js/translations/all_{locale}.min.js
我正在使用 symfony assetic 来管理 javascript 和 css 资产(缩小并合并到 1 个文件)
{% javascripts
'@CmsBundle/Resources/public/js/translations/en.js'
'@TempBundle/Resources/public/js/jquery.js'
'@AppBundle/Resources/public/js/functions.js'
filter='?uglifyjs2'
output='@HomeBundle/Resources/public/js/all.min.js'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
此代码运行良好,在目录中输出 1 个文件:
@HomeBundle/Resources/public/js/all.min.js
我想根据请求的语言环境添加更多javascript 翻译文件
@CmsBundle/Resources/public/js/translations/en.js
@CmsBundle/Resources/public/js/translations/de.js
@CmsBundle/Resources/public/js/translations/fr.js
具有基于输入语言环境的内容的预期输出文件:
@HomeBundle/Resources/public/js/all_en.min.js
@HomeBundle/Resources/public/js/all_de.min.js
@HomeBundle/Resources/public/js/all_fr.min.js
我尝试使用变量生成本地化文件,其内容基于输入语言环境文件:
{% javascripts
'@CmsBundle/Resources/public/js/translations/*'
'@TempBundle/Resources/public/js/jquery.js'
'@AppBundle/Resources/public/js/functions.js'
filter='?uglifyjs2'
output='@HomeBundle/Resources/public/js/all_{locale}.min.js'
vars= ['locale']
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
配置资产:
assetic:
variables:
locale: [ en,de,fr ]
生成了 3 个语言环境文件,但内容相同,并合并了 3 个输出文件中的所有语言环境文件。
我希望文件 all_en.min.js
仅包含 en.js
和其他非语言环境 javascript 文件的内容
改变
@CmsBundle/Resources/public/js/translations/*
至
@CmsBundle/Resources/public/js/translations/all_{locale}.min.js