Welcome to my blog, stay tunned :
Home | Blogs | Stephane Eyskens's blog

Localization in SharePoint XSLT files used by custom field types

Hi,

If like me, you wonder how you can localize your SharePoint XSLT files, the ones you use in your custom field types and/or in your lists, here is how it works:

- You need to have a resource file, so for instance MyResource.resx, MyResource.en-US.resx and MyResource.fr-FR.resx
- You must deploy those resource files to the App_GlobalResources folder of the corresponding IIS web application. Now, you can easily do that with the new packaging mechanisms since SharePoint WSPs are now able to deploy directly in the web app folders.

- When those pre-requisites are respected, you can just use this:

<script language="JavaScript">
<![CDATA[
alert(']]><xsl:value-of select="$thisNode/../@resource.YourResourceFile.TheKey"/><![CDATA[';
]]>
</script>

in the "body" mode of your custom field type

and this, in the "header" mode of your custom field type:

<script language="JavaScript">
<![CDATA[
alert(']]><xsl:value-of select="$Rows/@resource.YourResourceFile.TheKey"/><![CDATA[');
]]>
</script>

This will grab the value of the key in the relevant resource file corresponding to the culture of the current web.

Happy Coding