Hi!
I need to connect different css files for different languages.
I tried to do it in this way
{% if activeLang == “en” %}
link href=“{{ [‘assets/css/en.css’]|theme }}” rel=“stylesheet”
{% elseif activeLang == “uk” %}
link href=“{{ [‘assets/css/uk.css’]|theme }}” rel=“stylesheet”
{% endif %}
Can somebody help me? My code doesn’t work.
instead of activeLang
use this.site.locale
and… of course if you use logic like {$locale}.css
then you can simplify
// wrong url ...
<link href="{{ 'assets/css/' ~ this.site.locale ~ '.css'|theme }}" rel="stylesheet">
// returns first part 'assets/css' ... then generated url to theme folder...
correct solution (sorry my bad)
{% set stylesheet = 'assets/css/' ~ this.site.locale ~ '.css' %}
<link href="{{ stylesheet|theme }}" rel="stylesheet">
// correct generation of stylesheet url
Thank you very much for the answer.
It seams to be exactly what I need.
But it doesn’t work properly. Below is two sreenshots to demonstrate the problem.
This solutions works for me.
link href=“{{ url(‘/’) }}/themes/golem-agency/assets/css/{{ this.site.locale}}.css” rel=“stylesheet”
It is not perfect, but it works
If anybody know how to fix the previous one, please reply to this conversation.
Thank you all for help.
no…
try this instead
{% set stylesheet = 'assets/css/' ~ this.site.locale ~ '.css' %}
<link href="{{ stylesheet|theme }}" rel="stylesheet">
2 Likes
It works perfectly.
Thank you
1 Like