Sharepoint 2010 - Change UI Language with javascript

If you want to use html/javascript to change UI language, you can use the script below:
(Note: in the page, there is the function OnSelectionChange, so you have to change name if you want to use other feature in)

function OnSelectionChange(value)
{
    var today = new Date();
    var oneYear = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);
    var url = window.location.href;
    document.cookie = "lcid=" + value + ";path=/;expires=" + oneYear.toGMTString();
    window.location.href = url;
}

And in page, set the flags for change language:

<a href="javascript:OnSelectionChange(1040)">
    <img width="32" height="20" src="/SiteAssets/flag_ita.png" border="0" alt="Italiano"/>
</a>
<a href="javascript:OnSelectionChange(1033)">
    <img width="32" height="20" src="/SiteAssets/flag_eng.png" border="0" alt="Inglese"/>
</a>

Comments

Popular posts from this blog

Sharepoint 2010 - Filter List/Library Web Part with XSLT and Content Editor WP

Sharepoint 2010 - Multilanguage Site - Show column in current language

Sharepoint 2010 - Enable/Disable Ribbon Button with EcmaScript