I'm a web designer working with SharePoint 2013. I created a custom template for a company and now I want to go further with variations capabilities. The website should be available in German and in English.

On the footer of the master page, I placed some hard-coded links like this:

<a href="/Authenticate.aspx">Login</a>
<a href="/imprint">Imprint</a>
<a href="/disclaimer">Disclaimer</a>

And I want them to rebuild dynamically to my variations site like this for the German language:

<a href="/de/...">Login</a>
<a href="/de/...">Imprint</a>
<a href="/de/...">Disclaimer</a>

or this for English:

<a href="/en/...">Login</a>
<a href="/en/...">Imprint</a>
<a href="/en/...">Disclaimer</a>

Is there a variable that I could place in front of the links in my master page? Or a method to get the current language?

I was thinking of something like this:

<a href="{Locale}/login">...</a>
<a href="$language/imprint...">...</a>
<a href="getLanguage()/disclaimer">...</a>

I'm not an ASP.NET coder, so I don't really know how find out the language. I would appreciate if someone could help me.

2 Answers 2


You could use the SPWeb.Locale property of the current context (as in SPContext.Current.Web.Locale) to glean this information.

If you look at the Remarks section of the CultureInfo Class description on MSDN it will explain this.

A simple example would be:

<a href="/<%= SPContext.Current.Web.Locale.TwoLetterISOLanguageName %>/Login.aspx">...</a>

I solved the problem with another method: I used SharePoints own Javascript variable - _spPageContextInfo - see: _spPageContextInfo is your new best friend !

With "currentCultureName" I could use the language name as a variable to compare to the target language and to expand my PageLayout with custom links, compliant to my variations settings.

The Code could look like this:

    $(document).ready(function() {

        $language = _spPageContextInfo.currentCultureName;

        // If it's german, I'll get german links
        if ($language == "de-DE") {
            $('.footer').html('<a href="/de/kontakt/">Kontakt</a>');
        } else {
        // And if not, it will target to the english page
            $('.footer').html('<a href="/en/contact">Contact</a>');

  • _spPageContextInfo.currentCultureName it's the method I use too. I see an alternative on Wictor Wilén blog and MSDN discussions using Strings.STS.L_CurrentUICulture_Name.
    – nilsandrey
    Sep 10, 2015 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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