forked from wp-cli/wp-cli.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlanguages.html
More file actions
34 lines (29 loc) · 909 Bytes
/
languages.html
File metadata and controls
34 lines (29 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<select id="languages" class="languages">
<option value="">Change Language</option>
{% for lang in site.languages %}
<option value="{{ lang.path }}">{{ lang.label }}</option>
{% endfor %}
</select>
<script type="text/javascript">
( function(){
'use strict';
var langs = document.getElementById( 'languages' );
// Only apply this after we set the Selected option
langs.onchange = function( ev ) {
if ( ev.currentTarget && ev.currentTarget.value ) {
location.href = ev.currentTarget.value;
}
};
if ( '/' === window.location.pathname ) {
return;
}
var opts = langs.getElementsByTagName( 'option' ),
count = opts.length;
for ( var i = 0; i < count; i++ ){
// Only happens if you have language path on the start of the location.pathname
if ( 0 === window.location.pathname.indexOf( opts[ i ].value ) ) {
opts[ i ].setAttribute( 'selected', 'selected' );
}
}
} )();
</script>