Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #99
- Loading branch information
Showing
6 changed files
with
126 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,35 @@ | ||
|
||
|
||
<select id="languages"> | ||
<!-- note on the options here: the 'title' string is to be translated in your | ||
language, but the element text is supposed to stay in native lang/txt --> | ||
<option value="fr" title="{{ _('French') }}">Français</option> | ||
<option value="en" title="{{ _('English') }}">English</option> | ||
<option value="es" title="{{ _('Spanish') }}">Español</option> | ||
<option value="it" title="{{ _('Italian') }}">Italiano</option> | ||
<option value="pt" title="{{ _('Portuguese') }}">Português</option> | ||
<option value="fi" title="{{ _('Finnish') }}">Suomalainen</option> | ||
<!-- <option value="ca_ES" title="{{ _('Catalan') }}">Catalan</option> | ||
<option value="da_DK" title="{{ _('Danish') }}">Dansk</option> | ||
<option value="de" title="{{ _('German') }}">Deutsch</option> | ||
<option value="fa" title="{{ _('Persian') }}">فارسی</option> | ||
<option value="id" title="{{ _('Indonesian') }}">Bahasa Indonesia</option> | ||
<option value="ja" title="{{ _('Japanese') }}">日本語</option> | ||
<option value="ko_KR" title="{{ _('Korean') }}">한국어</option> | ||
<option value="nl" title="{{ _('Dutch') }}">Nederlands</option> | ||
<option value="ro" title="{{ _('Romanian') }}">Română</option> | ||
<option value="ru" title="{{ _('Russian') }}">Русский</option> | ||
<option value="zh_CN" title="{{ _('Chinese (China)') }}">中文</option> | ||
<option value="zh_TW" title="{{ _('Chinese (Taiwan)') }}">{{ _('Chinese (Taiwan)') }}</option> --> | ||
{% for lang in lizmap_locales %} | ||
<option value="{{ lang }}" data-url="{{ lizmap_path_to_root }}../{{ lang }}/index.html" title="{{ lizmap_locales_name[lang] }}">{{ lizmap_locales_label[lang] }}</option> | ||
{% endfor %} | ||
</select> | ||
|
||
<span id="versions-links"> | ||
Versions: | ||
<span id="versions-links-list"> | ||
{% for liz_vers, liz_label, liz_link in lizmap_versions.list %} | ||
{% if liz_vers == lizmap_versions.next_version%} | ||
{% if version == lizmap_versions.next_version %}<strong class="verlink">{{ liz_label }}</strong>{% endif %} | ||
{%else%} | ||
{% if liz_vers == version %} | ||
<strong class="verlink">{{ liz_label }}</strong> | ||
{% else %} | ||
<a class="verlink" href="{{ lizmap_path_to_root }}../../{{ liz_link }}/{{ language }}/" title="{{ liz_label }}">{{ liz_label }}</a> | ||
{% endif %}{% endif %} | ||
{% endfor %} | ||
</span> | ||
</span> | ||
|
||
<script> | ||
var currentPage = '{{current_page_name}}.html'; // coming from sphinx, always without starting '/' | ||
var currentLang = 'en'; | ||
// split index.html if currentUrl is ended by '/' | ||
var currentUrl = window.location.href; | ||
if (currentUrl.slice(-1) == '/' && currentPage.slice(-1) != '/'){ | ||
var pages = currentPage.split('/'); | ||
pages.pop(); | ||
currentPage = pages.join('/') + '/'; | ||
} | ||
var currentPage = '{{current_page_name}}.html'; // coming from sphinx, always without starting '/'; | ||
var currentLang = '{{ language }}'; | ||
document.addEventListener("DOMContentLoaded", function(){ | ||
var search = new RegExp('\/[a-zA-Z_]{2,8}\/'+ currentPage, 'gi'); | ||
var langPlusPage = window.location.href.match(search); | ||
// it's possible this is the 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('This is an documentation error, please report back to QGIS devs.'); | ||
return; | ||
} | ||
langPlusPage = langPlusPage[0]; | ||
currentLang = langPlusPage.replace(currentPage, ''); | ||
if (currentLang[0] != '/') | ||
currentLang = '/'+currentLang; | ||
// 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 | ||
var selectLanguage = document.getElementById("languages"); | ||
selectLanguage.value = currentLang.replace(/\//g,''); // currentLang is something like '/nl/' | ||
|
||
selectLanguage.value = currentLang; | ||
selectLanguage.addEventListener("change", function(event) { | ||
gotoLang(event.target.value); | ||
window.location.href = event.target.selectedOptions[0].getAttribute('data-url'); | ||
}, false); | ||
|
||
}, false); | ||
|
||
// 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"list" : [ | ||
["3.2", "Lizmap 3.2", "3.2"], | ||
["3.1", "Lizmap 3.1/3.0/2.x", "3.1"], | ||
["3.3", "Development version", "next"] | ||
], | ||
"locales" : { | ||
"3.1": [ "fr", "en", "it", "es", "pt", "fi"], | ||
"3.2": [ "fr", "en", "it", "es", "pt", "fi"], | ||
"3.3": [ "fr", "en", "it", "es", "pt", "fi"] | ||
}, | ||
"stable_version" : "3.2", | ||
"next_version" : "3.3" | ||
} |