Need a simple CRM and Project Management system?
Check out JobNimbus - CRM for Contractors and Service Professionals.

Internationalize / Localize ASP.NET Javascript

I ran across an interesting presentation today on how to internationalize javacripts in ASP.NET. The presentation was given in January 2008 by Guy Smith-Ferrier and is a continuation based on his article in MSDN Magazine from January 2008 called Around the World with ASP.NET AJAX Applications.

You can download it as a PDF here.



One thing I found further today to localize a resource in javascript is that you can actually load a resource string directly into a javascript string directly.

You can reference a string in a resource assembly with this javascript syntax:

var myResourceString = '<%= MyResourceAssemblyName.SharedResources.strHelloWorld %>';

MyResourceAssemblyName is the name of the Assembly where your resource string is located. SharedResources is the name of the .resx file in the assembly that contains the string. strHelloWord is the ID of the resource string to retrieve.

Of course, this code needs to be embedded in an .ASPX page so that it can be interpreted when served because .js files are not parsed by the ASP.NET runtime.