Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
1.1k views
in SharePoint Server by 30 37 42

Is it possible to read an entry from global resource file in ItemStyle.XSL in SharePoint 2019?

I have already implemented the Variations in SharePoint site, and one of my custom styles has a static string that was added in ItemStyle.xsl file as is!

<span class="more">
  <a href="{$SafeLinkUrl}">More....</a>
</span>

But I need to apply multilingual content for this style to show this string value "More...." based on the current site language and not to be static!

I checked Localizing contents of the Content Query Web Part using custom XSLT functions but I am not familiar with the custom XSLT function for the Content Query web part? Is there any new way to implement multilingual in ItemStyle.xsl file in SharePoint on-premises?


1 Answer

1 like 0 dislike
by 162 202 397
selected by
 
Best answer

Is it possible to localize CQWP content from the global resource file?

Unfortunately, NO! In SharePoint ItemStyle.XSL, you can't localize the Content Query Web Part Content using a global resource file as OOTB!

Does XSLT support Localization?

NO, XSLT doesn’t provide any kind of localization!

Workaround to implement multilingual in SharePoint ItemStyle.xsl file

Fortunately, you have two options to deal with different languages and localize Content Query Web Part content in SharePoint ItemStyle.xsl file like the following:

  1. Using custom XSLT functions to localize contents of the Content Query Web Part as mentioned at Localizing Content Query Web Part XSL templates
  2. Using XSL-CHOOSE to switch between languages based on a part of the current Page URL.

Localizing the Content of Content Query Web Part (Option #2)

This option is simple and easy to implement in case you would like to localize a bit of content like a label in your ItemStyle!

Steps

  1. Define a parameter to get the current Page URL as mentioned at Get Current Page URL in XSLT SharePoint ItemStyle
  2. Define a variable called Lang and set it to the represented language part in your Page URL as the following:

        <xsl:variable name="Lang" select="'/en/'" />
    
  3. Then, check if the current Page URL contains this part or not as below
  4. Finally, perform XSL-CHOOSE statement to handle the displayed language as the following:

         <xsl:choose>
             <xsl:when test="contains($PageUrl,$Lang)">
               More
             </xsl:when>
            <xsl:otherwise>
              المزيد
            </xsl:otherwise>
         </xsl:choose>
    
by 30 37 42
0 0
It's a great workaround, thank you!
If you don’t ask, the answer is always NO!
...