0

I have the following structure for the css files Public - css -- fr --- style.css -- en --- style.css

the css folder include fr and en folders

and I'm including CSS stylesheets in my template like so:

{% stylesheets '@AtgNewsBundle/Resources/public/css/*' filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}

so i need to include the fr or en folder as user selection

i tried the following but does not work

{% stylesheets '@AtgNewsBundle/Resources/public/css/{app.request.getLocale()}/*' filter='cssrewrite' %}

{% stylesheets '@AtgNewsBundle/Resources/public/css/{{app.request.getLocale()}}/*' filter='cssrewrite' %}

{% stylesheets '@AtgNewsBundle/Resources/public/css/"{{app.request.getLocale()}}"/*' filter='cssrewrite' %}

any help please

ghaidaa84
  • 3
  • 1

2 Answers2

0

You should use the right concatenate operator:

{% stylesheets '@AtgNewsBundle/Resources/public/css/' ~ app.request.getLocale() ~ '/*' filter='cssrewrite' %}

If you prefer to do string interpolation (less readable IMHO), you should use:

{% stylesheets '@AtgNewsBundle/Resources/public/css/#{app.request.getLocale()}/*' filter='cssrewrite' %}
Alain Tiemblo
  • 36,099
  • 17
  • 121
  • 153
0

You can do it this way:

{% if app.request.locale=="fr" %}

{% stylesheets '@AtgNewsBundle/Resources/public/css/fr/*' filter='cssrewrite' %}

{% elseif app.request.locale=="en" %}

{% stylesheets '@AtgNewsBundle/Resources/public/css/en/*' filter='cssrewrite' %}

{% endif %}
enigma
  • 493
  • 2
  • 5
  • 18