templates/static/proxy.html.twig line 1

  1. {# this proxy template tries to get:
  2. 1- the current locale page: static/{page}_{locale}.html.twig
  3. 2- if not exists then it tries to get the default locale page: static/{page}_ar.html.twig
  4. 3- if not exists then fallback to the common page (non localized) : static/{page}.html.twig #}
  5. {# [1] get default locale (Arabic) that will be used if no template for the current locale #}
  6. {% set available_locales = app_locales|split('|') %} {# get locales from config #}
  7. {% set locale_codes = [] %}
  8. {% for key, value in available_locales %}
  9.     {% set locale_codes = locale_codes|merge({ (value): value }) %} {# no way to push to an array in twig except via merging to it #}
  10. {% endfor %}
  11. {% set default_locale= locale_codes['ar'] %}
  12. {# [2] extending the appropriate twig template depending on "page" route parameter and the current locale #}
  13. {% set localized_template_path = "static/" ~ app.request.get('page') ~ "_" ~ app.request.locale ~  ".html.twig" %}
  14. {% set default_template_path = "static/" ~ app.request.get('page') ~ "_" ~ default_locale ~  ".html.twig" %}
  15. {% set non_localized_template_path = "static/" ~ app.request.get('page') ~  ".html.twig" %}
  16. {% extends [localized_template_path, default_template_path, non_localized_template_path] %}