Question

I am using XSLT (xml version='1.0') in Visual Studio ASP.NET 4.0.

I am using a product that is available in multiple languages, but I cannot get nsxsl:format-date to respect the current language. For example, if I have set the current culture to French, and I write:

<xsl:value-of select="msxsl:format-date('31/05/2013', 'dd-MMM-yyyy')"/>

I would expect it output something like "31-Mai-2013".

Unfortunately, the 'month' portion is not translated. It always returns the english version ('May').

The MSDN documentation suggests adding a 3rd optional parameter (locale) to specify the culture, but it doesn't say what the default behaviour is if you omit the 'locale' parameter.

So, if the 'locale' parameter is omitted, where does format-date() use as it's default locale? And how can I change this default behaviour?

Thanks for any help you can offer!

Was it helpful?

Solution

If you omit the locale, then the XSLT defaults to the installation language of the XSLT processor you're using, the 1.0 one. (MS XSL Utility msxsl.exe or Visual Studio etc.) Doesn't matter what is the locale of the browser or your asp.net application.

In order to make it locale aware with least effort, you need to declare a variable (say with value "EN_us") and use it as the third parameter in all such date, time, number formatting functions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top