1

I have a site that will be English/Spanish, when clicking Spanish link the site will be in spanish language, when clicking English the site will be in English.

The site will use variation, and I am doing the master page.

How can I handle the links in the master page to change from one language to another? also how can I handle the link to change the language? how can this be packaged?

Thanks

0

I positioned two flags on the top right and gave them fixed links like "/en" or "/es"; if clicked the user will be redirected to the respective language. There is also the possibility to redirect the user via javascript. If it's not my default language, get the other version.

<script type="text/javascript">
function redirectThis() {
    $url = "/en/site";
    $timeout = 1000;
    if(_spPageContextInfo.currentCultureName != "de-DE") {
        alert("You'll be redirected to the english version of this page.");
        window.setTimeout('window.location = $url', $timeout);
    }
}
_spBodyOnLoadFunctionNames.push("redirectThis");
</script>

For other hardcoded links (e.g. on the footer: Contact/Disclaimer..) I used Javascript/jQuery to rewrite them depending on the used language and using Sharepoints Javascript variable _spPageContextInfo

$language = _spPageContextInfo.currentCultureName;
if ($language == "de-DE") {
    $('.footerlinks').html('<a href="/de/kontakt/" title="Kontakt">Kontakt</a>');
} else {
    $('.footerlinks').html('<a href="/en/contact/" title="Contact">Contact</a>');
}

I'm not sure if this works out for you but it's how I solved some of the problems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.