Add a language toggle link
iShare sites that cater for multiple languages (e.g. English and Welsh) are configured using Workspaces (please see the iShare Languages page for more information). Commonly multi-lingual sites will require a link to toggle from one language to the other.
For example a "Cymraeg" link might be displayed on the English language site while an "English" link is displayed on the Welsh site.
As it's common for the different sites to have a unique domain name the current tab and address are not automatically preserved when switching from one language to another. This script attempts to preserve the current tab and address information when a user switches to another language.
Step-by-step guide
Add a link to each .aspx page such as the following on the Welsh page:
<a href="http://maps.anglesey.gov.uk/" class="toggle">English</a>
Add the following code to each page (commonly within the customJS function), adjusting 'MyNearest' and 'MyMaps' to match your MapSource names:
// Try and ensure switching language maintains address and tab function getTabNum() { try { var cookie = document.cookie.split('; ').filter(function (cookie) {return cookie.startsWith('atMyCouncil')})[0]; if (cookie.indexOf('MyNearest') >= 0) { return 1; } else if (cookie.indexOf('MyMaps') >= 0) { return 2; } return 0; } catch (e) {} } function getUid() { try { var cookie = document.cookie.split('; ').filter(function (cookie) {return cookie.startsWith('astun:currentLocation')})[0]; return JSON.parse(cookie.split('=', 2)[1]).uid; } catch (e) {} } jQuery(function() { // Update the language toggle link to include the tab and UPRN of the address jQuery('.toggle').attr('href', jQuery('.toggle').attr('href') + '?tab=' + getTabNum() + '&action=SetAddress&UniqueId=' + getUid()); });