Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions _static/faunalia.css
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,7 @@ text-shadow:none !important;
.nav-list > li > ul > li > a {
margin-left:10px !important;
}

.languageswitch-phone {
padding-left: 25%;
}
47 changes: 47 additions & 0 deletions _templates/languages-script.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<script type="text/javascript">
var currentPage = '{{current_page_name}}.html'; // coming from sphinx, always without starting '/'
var currentLang = 'en';
$(document).ready(function(){

var search = new RegExp('\/[azAZ_]{2,8}\/'+ currentPage, 'gi');
var langPlusPage = window.location.href.match(search);
// it's possible this is a index.html page called without 'index.html', try without the currentPage
if (langPlusPage==undefined){
search = new RegExp('\/[azAZ_]{2,8}\/$', 'gi');
langPlusPage = window.location.href.match(search);
}

// it's possible this is an index.html page called without 'index.html', try removing index.html
if (langPlusPage==undefined){
currentPage = currentPage.replace('index.html','')
search = new RegExp('\/[azAZ_]{2,8}\/'+ currentPage, 'gi');
langPlusPage = window.location.href.match(search);
}
// still no langPlugPage: stop, because the language swicher will misbehave

if (langPlusPage == undefined || langPlusPage.length != 1){
alert('You hit an error, please report back to us.');
return;
}
langPlusPage = langPlusPage[0];
currentLang = langPlusPage.replace(currentPage, '');
// put some style around the current locale flag, we have to remove the '/' here
// this is for the flags:
//$('#flag_'+currentLang.replace(/\//g,'')).css('backgroundcolor', '#cccccc');
// set language select to current lang

$(".languages").val(currentLang.replace(/\//g,'')); // currentLang is something like '/nl/'

$(".languages").change(function() {
gotoLang($(this).val());
});

});

// load current page in a different language
function gotoLang(lang){
var currentUrl = window.location.href;
var newUrl = currentUrl.replace(currentLang, '/'+lang+'/');
window.location.href = newUrl;
}
</script>
51 changes: 1 addition & 50 deletions _templates/languageswitch.html
Original file line number Diff line number Diff line change
@@ -1,59 +1,10 @@

<meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
<form role="form">
<select id="languages" class="form-control select-mini">
<select class="form-control select-mini languages">
<option value="en">English</option>
<option value="it">Italiano</option>
<option value="pt">Português</option>
<option value="fr">Français</option>
<option value="es">Español</option>
</select>
</form>
<script>
var currentPage = '{{current_page_name}}.html'; // coming from sphinx, always without starting '/'
var currentLang = 'en';
$(document).ready(function(){

var search = new RegExp('\/[a-zA-Z_]{2,8}\/'+ currentPage, 'gi');
var langPlusPage = window.location.href.match(search);
// it's possible this is a index.html page called without 'index.html', try without the currentPage
if (langPlusPage==undefined){
search = new RegExp('\/[a-zA-Z_]{2,8}\/$', 'gi');
langPlusPage = window.location.href.match(search);
}

// it's possible this is an index.html page called without 'index.html', try removing index.html
if (langPlusPage==undefined){
currentPage = currentPage.replace('index.html','')
search = new RegExp('\/[a-zA-Z_]{2,8}\/'+ currentPage, 'gi');
langPlusPage = window.location.href.match(search);
}
// still no langPlugPage: stop, because the language swicher will misbehave

if (langPlusPage == undefined || langPlusPage.length != 1){
alert('You hit an error, please report back to us.');
return;
}
langPlusPage = langPlusPage[0];
currentLang = langPlusPage.replace(currentPage, '');
// put some style around the current locale flag, we have to remove the '/' here
// this is for the flags:
//$('#flag_'+currentLang.replace(/\//g,'')).css('background-color', '#cccccc');
// set language select to current lang

$("#languages").val(currentLang.replace(/\//g,'')); // currentLang is something like '/nl/'

$("#languages").change(function() {
gotoLang($(this).val());
});

});

// load current page in a different language
function gotoLang(lang){
var currentUrl = window.location.href;
var newUrl = currentUrl.replace(currentLang, '/'+lang+'/');
window.location.href = newUrl;
}
</script>

9 changes: 8 additions & 1 deletion _templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<span class="icon-bar"></span>
</button>

<div class="visible-xs languageswitch-phone">
{% block languageswitchphone %}
{% include "languageswitch.html" %}
{% endblock %}
</div>

<a class="navbar-brand" href="{{ pathto(master_doc) }}">{% if theme_navbar_title -%}{{ theme_navbar_title|e }}{%- else -%}{{ project|e }}{%- endif -%}</a>
<span class="navbar-text navbar-version pull-left"><b>{{ version|e }}</b></span>
</div>
Expand All @@ -35,7 +41,7 @@

{% block navbarextra %}
{% endblock %}
<li>
<li class="hidden-xs">
{% block languageswitch %}
{% include "languageswitch.html" %}
{% endblock %}
Expand Down Expand Up @@ -134,4 +140,5 @@ <h3>{{ gettext('Seguici') }}</h3>
</div></div>
</div>
</footer>
{% include "languages-script.html" %}
{%- endblock %}