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:
- Using custom XSLT functions to localize contents of the Content Query Web Part as mentioned at Localizing Content Query Web Part XSL templates
- 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
- Define a parameter to get the current
Page URL
as mentioned at Get Current Page URL in XSLT SharePoint ItemStyle
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/'" />
- Then, check if the current Page URL contains this part or not as below
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>