For a project I'm developing a multi-lingual site. The site contains an App part that should display localized content, depending on which variation label site the user is browsing the site. Consider I have the following two sites:

- http://example.com/en
- http://example.com/nl

Both contains the same app. The app's querystring receives the {StandardTokens} (specified in the AppManifest.xml). When the app is loaded inside SharePoint, the following iframe href is always generated:


The URL decoded redirect_uri querystring parameter is:


As you can see above the standardly generated SPLanguage querystring parameter is always "en_US", regardless of the language the user has chosen on the site. MSDN however indicates that SPLanguage should pass "the current language/culture of the host web of an app for SharePoint."

Am I doing something wrong or isn't the SPLanguage querystring parameter meant to pass the current selected language to the app?


After spending hours to figure out why the SPLanguage didn't change, writing down my problem seemed to do the trick. The simple answer is that the SPLanguage querystring parameter displays the "Language" attribute of the selected variation. This "Language" column specifies the language pack that is used for the specified label. In my case though (a public facing website), I want the language pack to be the same for all the variations, so the administrators don't stumble upon a French version of SharePoint (for example) when they have to publish a French article on the site.

So in my case, the variation settings look like this:

My variations setup

This creates four sites, all with an English administration panel, but with different locales (content languages). To pass the locale I think the only option is to use javascript and change the SPLanguage=en_US based on the label name.

In case anyone runs into the same issue, this is how you could solve it:

<script type="text/javascript">
// This block will make our MVC apps use the labels language.
$(function() {
    //get the url from iframe on page
    var src = $("iframe[src*='appredirect']").attr("src");

    if (src != null) {
        var iframeUrl = src.substring(0, src.indexOf("?"));
        var queryString = getQueryString(src);
        var redirectUrl = queryString["redirect_uri"];
        var clientID = queryString["client_id"];

        //Modify the redirectUrl with our language.
        redirectUrl = GetModifiedRedirectUrl(redirectUrl);

        //Piece together the new Url.
        var newUrl = iframeUrl + "?redirect_uri=" + redirectUrl + "&client_id=" + clientID;

        //update the SRC in the IFRAME
        $("iframe[src*='appredirect']").attr("src", newUrl);

//This function takes the old RedirectUrl and modifies it to our needs (updating the SPLanguage and insert the MvcUrl).
function GetModifiedRedirectUrl(originalRedirectUrl) {
    //First decode because the URL is passed encoded in a querystring.
    var decodedUrl = decodeURIComponent(originalRedirectUrl);

    //Now split the decoded redirect Url
    var urlFragments = decodedUrl.split("?");
    var baseUrl = urlFragments[0];
    var queryString = UpdateQueryStringLanguage(urlFragments[1]);

    //Piece together the new URL.
    var newUrl = baseUrl + "?" + queryString;

    return encodeURIComponent(newUrl);

//This function alters the SPLanguage parameter to the label the user is navigation.
//In our setup every variation has the same language pack specified in SharePoint. This results in SPLanguage will always equal "en_US".
function UpdateQueryStringLanguage(queryString) {
    //Get the label (language) the user is browsing.
    var currentLabel = window.location.href.split("/")[3];

    //Replace the generated language with our language.
    return queryString.replace("SPLanguage=en%2DUS", "SPLanguage=" + currentLabel);

function getQueryString(url) {
    //split up the pieces of the URL
    var vars = [], hash;

    var hashes = url.slice(url.indexOf("?") + 1).split("&");

    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split("=");
        vars[hash[0]] = hash[1];

    return vars;

For me, this is a workaround, but I would rather choose this than having our administrators need to learn to use SharePoint in different languages. If someone has a better solution, please feel free to share it!

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.