According to this MSDN documentation about XSLT global parameters, in main.xsl there is a parameter named LCID whose value should be

the value of System.Threading.Thread.CurrentThread.CurrentUICulture.LCID in string format.

I tried to use it in my DataFormWebPart. I firstly imported the main.xsl file, then tried to output the value of the $LCID parameter, but nothing is shown.

<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<xsl:import href="/_layouts/xsl/main.xsl"/>
<xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
<xsl:value-of select="$LCID"></xsl:value-of>

The value-of $LCID is simply empty. All the other parameters defined in main.xsl work properly (which is extremely irritating, considering that the one that I need it's the only that doesn't seem to work).

If I use this trick:

<ParameterBinding Name="Language" Location="Resource(wss,language_value)" />

then I can get the user's language in the form en-us, but I feel it as a dirty workaround.

So the question is: why is $LCID empty? How can I get the current user's LCID ?

  • @ArsalanAdamKhatri curly brackets inside the select attribute of a xsl:value-of are illegal (also tried with an asp:label text="{$LCID}" but still nothing is output). – MdMazzotti Jan 23 '14 at 11:44
  • I've run into the same issue. I see that is file is imported in the OOTB XSLT in the hive. My XSL is in the Style Library. Is that your case as well? – Gabriel Smoljár Jun 27 '14 at 12:25
  • @GabrielSmoljár I customized the XSLT in SP Designer, so in my case I didn't even have a separate xsl – MdMazzotti Jun 28 '14 at 8:42

I had a similar problem with getting the LCID within an event receiver. Finally I addressed it like this System.Globalization.CultureInfo.CurrentUICulture.LCID or System.Globalization.CultureInfo.CurrentUICulture.Name

It worked for me. Hope it helps.

  • 1
    I was looking for a way to get the LCID in the xsl stylesheet without recurring to a C# code solution – MdMazzotti Jul 19 '14 at 15:03

Knowing how sensitive xslt is, have you tried:

    <xsl:value-of select="$LCID"/>

Also look into your xsl:output method.


Use this

<xsl:stylesheet ...>
    <xsl:param name="Language" />
    <xsl:template match="/" xmlns...>
        <xsl:value-of select="$Language" />

Reference: https://msdn.microsoft.com/en-us/library/dd583143%28v=office.11%29.aspx?f=255&MSPPError=-2147217396.

  • Nope. This is the value of the site's LCID, not the current user's LCID, which are two completely different things. – MdMazzotti May 13 '15 at 18:02

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.