Skip to content

Commit

Permalink
multilingual field takes into accout currentl locale
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducica committed Nov 12, 2024
1 parent e954b6d commit 77d9e64
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions oarepo_ui/templates/components/Multilingual.jinja
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
{# def data #}
{%if data%}
{% if data %}
{# issue in Jinja while setting a variable inside of the loop. namespace solves the issue #}
{% set ns = namespace(language_found=False) %}
{% for item in data %}
{% if item.lang == current_i18n.language %}
{% set ns.language_found = True %}
{% endif %}
{% endfor %}

<div class="ui multilingual-tabs">
<div class="ui compact text menu separated">
{% for item in data %}
<a class="green item {{'active' if loop.first else ''}}" data-tab="{{item|id}}-{{item.lang|e}}">{{item.lang|upper}}</a>
<a class="green item
{{ 'active' if (item.lang == current_i18n.language and ns.language_found) or
(loop.first and not ns.language_found) else '' }}"
data-tab="{{ item|id }}-{{ item.lang|e }}">
{{ item.lang|upper }}
</a>
{% if not loop.last %}
<div class="separator"><div class="vertical-bar"></div></div>
<div class="ui separated"><div class="single separator"></div></div>
{% endif %}
{% endfor %}
</div>

{% for item in data %}
<div class="ui tab {{'active' if loop.first else ''}}" data-tab="{{item|id}}-{{item.lang|e}}">
<div class="ui tab
{{ 'active' if (item.lang == current_i18n.language and ns.language_found) or
(loop.first and not ns.language_found) else '' }}"
data-tab="{{ item|id }}-{{ item.lang|e }}">
{{ item.value|safe }}
</div>
{% endfor %}
Expand Down

0 comments on commit 77d9e64

Please sign in to comment.