In other words, you want to load the right CSS file according to your locale.
Twig lets you handle this seamlessly. Here is an example of how you can do this,
First create a global template app/Resources/views/base.twig.html containing
{% block head %} {% block direction %} <HTML> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> {% endblock %} <head> {% endblock %}
Then you can add a version of your base template in English and Persian (or any other language)
application / resources / views / base.en.html.twig
{% extends '::base.html.twig' %}
In the Persian version of your base template, and since you need RTL for html and custom CSS, you need to install more details about this,
app / Resources / views / base.fa.html.twig (I think "fa" is the language code for the Persian language)
{% extends '::base.html.twig' %} {% block direction %} <HTML DIR="RTL"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> {% endblock %} {% block stylesheet %} {{ parent() }} {% endblock %}
Then, using a three-tier membership, you can inherit from the right base template according to your locale. Here, what your layout should contain,
{% extends '::base.' ~ app.request.locale ~ '.html.twig' %}
source share