{% if translations_by_language is defined %}
{% set sCurrGroupName = '' %}
{% set bHasTrans2 = (translation2 is defined and translation2 is not null) %}
{% set bHasTrans3 = (translation3 is defined and translation3 is not null) %}
{% set sLinkTarget = "" %}
{% if bInFrame %}
{% set sLinkTarget = " target=_top " %}
{% endif %}
{% set sPopup = "" %}
{% set bAllTrans = (all_translations is defined) %}
{% if content_type is defined and content_type == 'single_verse' %}
{% set sUrl1 = "" %}
{% if not bAllTrans %}
{% set sUrl1 = path('bible_verse_all_translations', {'bookUrl': book_url, 'chapterIndex': chapter_index, 'verseIndex': verse_index}) %}
{% set sPopup = sPopup~'<button type="button" onclick="javascript:showhideDiv();top.location.href = \'{{ sUrl1 }}\';" class="btn btn-secondary" style="text-align:left; color:#000; background-color: #f8f9fa; border: 1px solid rgba(0, 0, 0, 0.125);">' ~ app.session.get('ui_str')["popup.allbibletranslations"] ~ '</button><br><br>' %}
{% else %}
{% endif %}
{% endif %}
{% for other_translation in translations_by_language %}
{% if other_translation["group_name"] != sCurrGroupName %}
{% if sCurrGroupName != '' %}
{% set sPopup = sPopup~'</div></div></div><div class="row"><div class="col">' %}
{% endif %}
{% set sPopup = sPopup~'<h4>' ~ other_translation.group_name ~ '</h4><div class="btn-group-vertical" role="group" aria-label="Vertical button group" style="width:100%;padding-bottom:15px;">' %}
{% set sCurrGroupName = other_translation.group_name %}
{% endif %}
{% set the_story = null %}
{% if route_story is defined and route_story is not null %}
{% set the_story = route_story %}
{% elseif story is defined and story is not null %}
{% set the_story = story %}
{% endif %}
{% set book_url = null %}
{% if(canonical_book is defined and canonical_book is not null and other_translation["has_book"]) %}
{% set book_url = canonical_book.url %}
{% else %}
{% set book_url = other_translation["first_book_url"] %}
{% endif %}
{% set nChapterStart = 1 %}
{% set nChapterEnd = null %}
{% set bHasChapter = other_translation["has_chapter"] %}
{% if bHasChapter and canonical_chapter_start is defined and canonical_chapter_start is not null %}
{% set nChapterStart = canonical_chapter_start %}
{% set nChapterEnd = canonical_chapter_end %}
{% endif %}
{% set sUrl = "" %}
{% if other_translation["id"] == currTranslation.id %}
{% elseif (dropdown_target == 1 and translation2 is not null and other_translation["id"] == translation2.id) or (dropdown_target == 1 and bHasTrans3 and other_translation["id"] == translation3.id) or (dropdown_target == 2 and translation1 is not null and other_translation["id"] == translation1.id) or (dropdown_target == 2 and bHasTrans3 and other_translation["id"] == translation3.id) or (dropdown_target == 3 and translation1 is not null and other_translation["id"] == translation1.id) or (dropdown_target == 3 and translation2 is not null and other_translation["id"] == translation2.id) %}
{# disabled #}
{% set first_book = other_translation["first_book_url"] %}
{% if first_book is not null and first_book != '' %}
{% set sUrl = path('bible_book', {'translationUrl': other_translation["url"], 'bookUrl': other_translation["first_book_url"]}) %}
{% else %}
{# disabled #}
{% endif %}
{% elseif dropdown_target == 'index' %}
{% set sUrl = path('bible_translation', {'translationUrl': other_translation["url"]}) %}
{% elseif readingplan and plan_step is defined %}
{% set sUrl = path('reading_plan_step_translated', {'readingPlanUrl': reading_plan_url, 'stepOrder': plan_step.step_order, 'translationUrl': other_translation["url"]}) %}
{% elseif quickview and chapter_id is defined %}
{% set sUrl = path('quickview_bible_translation_chapter', {'translationId': other_translation["id"], 'chapterId': chapter_id}) %}
{% elseif dropdown_target is null %}
{% if content_class is defined and content_class == 'storytext' %}
{% set sUrl = path('bible_translated_story_text', {'storyUrl': story.url, 'bibleTranslationUrl': other_translation["url"]}) %}
{% elseif canonical_chapter_start is defined and canonical_chapter_start is not null %}
{% if nChapterEnd is not null %} {# multi-chapter in canonical numbering #}
{% if canonical_verse_start is defined and canonical_verse_start is not null %} {# not complete canonical chapters #}
{% set sUrl = path('bible_canonicalized_chapter_verse_range', {'translationUrl': other_translation["url"], 'bookUrl': book_url, 'chapterStartIndex': nChapterStart, 'chapterEndIndex': nChapterEnd, 'verseStartIndex': canonical_verse_start, 'verseEndIndex': canonical_verse_end}) %}
{% else %} {# complete canonical chapters #}
{% set sUrl = path('bible_canonicalized_chapter_range', {'translationUrl': other_translation["url"], 'bookUrl': book_url, 'chapterStartIndex': nChapterStart, 'chapterEndIndex': nChapterEnd}) %}
{% endif %}
{% else %} {# single-chapter in canonical numbering #}
{% if bHasChapter %}
{% if canonical_verse_end is defined and canonical_verse_end is not null %} {# range of verses from single canonical chapter #}
{% set sUrl = path('bible_canonicalized_verse_range', {'translationUrl': other_translation["url"], 'bookUrl': book_url, 'chapterStartIndex': nChapterStart, 'verseStartIndex': canonical_verse_start, 'verseEndIndex': canonical_verse_end}) %}
{% elseif canonical_verse_start is defined and canonical_verse_start is not null %} {# single canonical verse #}
{% set sUrl = path('bible_canonicalized_verse', {'translationUrl': other_translation["url"], 'bookUrl': book_url, 'chapterStartIndex': nChapterStart, 'verseStartIndex': canonical_verse_start}) %}
{% elseif content_type is defined and content_type == 'single_verse' %} {# single verse #}
{% set sUrl = path('bible_canonicalized_verse', {'translationUrl': other_translation["url"], 'bookUrl': book_url, 'chapterStartIndex': chapter_index, 'verseStartIndex': verse_index}) %}
{% else %} {# complete single canonical chapter #}
{% if bInFrame %}
{% set sUrl = path('bible_new', {'translationUrl': other_translation["url"], 'bookUrl': book_url, 'chapterIndex': nChapterStart}) %}
{% else %}
{% set sUrl = path('bible_chapter', {'translationUrl': other_translation["url"], 'bookUrl': book_url, 'chapterIndex': nChapterStart}) %}
{% endif %}
{% endif %}
{% else %}
{% set sUrl = path('bible_chapter', {'translationUrl': other_translation["url"], 'bookUrl': book_url, 'chapterIndex': nChapterStart}) %}
{% endif %}
{% endif %}
{% else %}
{# disabled #}
{% endif %}
{% elseif dropdown_target != 'multicolumn' %} {# dropdown_target is either 1 or 2 or 'add', but other_translation is not one that's currently shown #}
{% if dropdown_target == 'add' %}
{% if two_column is defined and two_column %}
{% set translation1_new, translation2_new, translation3_new = translation1, translation2, other_translation %}
{% else %}
{% set translation1_new, translation2_new = translation, other_translation %}
{% endif %}
{% elseif dropdown_target == 1 %}
{% if translation3 is defined and translation3 is not null %}
{% set translation1_new, translation2_new, translation3_new = other_translation, translation2, translation3 %}
{% else %}
{% set translation1_new, translation2_new = other_translation, translation2 %}
{% endif %}
{% elseif dropdown_target == 2 %}
{% if translation3 is defined and translation3 is not null %}
{% set translation1_new, translation2_new, translation3_new = translation1, other_translation, translation3 %}
{% else %}
{% set translation1_new, translation2_new = translation1, other_translation %}
{% endif %}
{% elseif dropdown_target == 3 %}
{% set translation1_new, translation2_new, translation3_new = translation1, translation2, other_translation %}
{% endif %}
{% if verse_index is defined and verse_index is not null %}
{% set path_name = 'bible_compare_verse' %}
{% set canonical_verse_start = verse_index %}
{% elseif canonical_verse_start is null %}
{% if nChapterEnd is null %}
{% set path_name = 'bible_compare_chapter' %}
{% else %}
{% set path_name = 'bible_compare_chapters' %}
{% endif %}
{% else %}
{% if canonical_verse_end is null %}
{% set path_name = 'bible_compare_verse' %}
{% elseif nChapterEnd is null %}
{% set path_name = 'bible_compare_chapter_verses' %}
{% else %}
{% set path_name = 'bible_compare_chapters_verses' %}
{% endif %}
{% endif %}
{% if (translation3 is defined and translation3 is not null) or (dropdown_target == 'add' and two_column is defined and two_column) %}
{% set sUrl = path(path_name~"_3col", {'translationUrl1': translation1_new.url, 'translationUrl2': translation2_new.url, 'translationUrl3': translation3_new.url, 'bookUrl': book_url, 'chapterStartIndex': nChapterStart, 'chapterEndIndex': nChapterEnd, 'verseStartIndex': canonical_verse_start, 'verseEndIndex': canonical_verse_end}) %}
{% else %}
{% set sUrl = path(path_name, {'translationUrl1': translation1_new.url, 'translationUrl2': translation2_new.url, 'bookUrl': book_url, 'chapterStartIndex': nChapterStart, 'chapterEndIndex': nChapterEnd, 'verseStartIndex': canonical_verse_start, 'verseEndIndex': canonical_verse_end}) %}
{% endif %}
{% elseif route_story is defined and route_story is not null %}
{% if commentary_url_from_link is defined and commentary_url_from_link is not null %}
{% set sUrl = path('bible_translated_story_for_commentary', {'storyUrl': story.url, 'bibleTranslationUrl': other_translation["url"], 'commentaryUrl': commentary_url_from_link}) %}
{% else %}
{% set sUrl = path('bible_translated_story', {'storyUrl': story.url, 'bibleTranslationUrl': other_translation["url"]}) %}
{% endif %}
{% else %} {# dropdown_target == 'multicolumn' and other_translation != translation and there is no route_story #}
{% if translate_pattern is defined and translate_pattern is not null %}
{% set sUrl = path(multicolumn_path, multicolumn_route_params|merge({('column'~column_num~'Details'): translate_pattern~other_translation["id"]}) ) %}
{% else %}
{% if bHasChapter %}
{% set sUrl = path(multicolumn_path, multicolumn_route_params|merge({('column'~column_num~'Details'): translate_pattern1~other_translation["url"]~'_'~book_url~translate_pattern2}) ) %}
{% else %}
{% set sUrl = path(multicolumn_path, multicolumn_route_params|merge({('column'~column_num~'Details'): translate_pattern1~other_translation["url"]~'_'~book_url~'_1'}) ) %}
{% endif %}
{% endif %}
{% endif %}
{% if sUrl != "" %}
{% set sPopup = sPopup~'<button type="button" onclick="javascript:showhideDiv();top.location.href = \'' ~ sUrl ~ '\';" ' ~ sLinkTarget ~ ' class="btn btn-secondary" style="text-align:left; color:#000; background-color: #f8f9fa; border: 1px solid rgba(0, 0, 0, 0.125);">' ~ other_translation["name"] ~ '</button>' %}
{% else %}
{% set sPopup = sPopup~'<button type="button" class="btn btn-secondary" style="text-align:left; color:grey; background-color: #f8f9fa; border: 1px solid rgba(0, 0, 0, 0.125);">' ~ other_translation["name"] ~ '</button>' %}
{% endif %}
{% endfor %}
{% set sPopup = sPopup~'</div></div>' %}
<script>
aPopupTranslation[{{ nPopupNum }}] = '{{ sPopup|replace({"'": "\\\'"})|raw }}';
</script>
{% endif %}