Skip to content

Commit ac9579b

Browse files
committed
Updated tutorial.html footer section to hold languageMenu code
Modified tutorial.html footer section to contain the languagemenu div for all pages.
1 parent bf0a7e9 commit ac9579b

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

_layouts/tutorial.html

+35
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,41 @@ <h2>{{ page.title | escape }}</h2>
116116
{% endif %}
117117
</div>
118118
<footer>
119+
<div class = "languageFooterMenu" >
120+
<select id="languageMenu" onchange="changeLanguage()">
121+
122+
{% assign languagesArray = 'English,Deutsch,Svenska' | split: ',' %}
123+
124+
{% for language in languagesArray %}
125+
{% assign lang = language | slice: 0, 2 | downcase %}
126+
{{ lang }}
127+
{{ page.lang }}
128+
{% if lang == page.lang %}
129+
<option id = page.lang selected href="..{{page.url}}" value="{{ page.url | remove: ".html"}}">{{language}}</option>
130+
{% endif %}
131+
{% if lang != page.lang %}
132+
<option id = "{{lang}}" href="..{{page.url | replace: page.lang, lang}}" value="{{ page.url | remove: ".html" | replace: page.lang, lang}}" >{{language}}</option>
133+
{% endif %}
134+
{% endfor %}
135+
</select>
136+
137+
<script>
138+
function changeLanguage() {
139+
var getLanguageMenu = document.getElementById('languageMenu');
140+
var getLanguageHref = getLanguageMenu.options[getLanguageMenu.selectedIndex].getAttribute('href');
141+
window.location.assign(getLanguageHref);
142+
143+
}
144+
</script>
145+
<script src="http://code.jquery.com/jquery-3.2.1.min.js"></script>
146+
<script>
147+
$(document).ready(function(){
148+
$("select").each(function(){
149+
$(this).val($(this).find('option[selected]').val());
150+
});
151+
});
152+
</script>
153+
</div>
119154
<div class="links">
120155
<a href="{{ site.data.localization.github.edit }}/{{ page.path }}">{{ site.data.localization.footer.edit[page.lang] }}</a>
121156
<a href="{{ site.data.localization.github.newIssue }}">{{ site.data.localization.footer.newIssue[page.lang] }}</a>

0 commit comments

Comments
 (0)