13.8. Embedding JavaScript Files

Another option for localizing your JavaScript files is to embed the files directly into the assembly. This approach is a bit different, but it also shows you how to achieve results similar to those just presented.

For this example, create an ASP.NET Web Application Project by selecting File New Project rather than File New Web Site. Instead of creating multiple scripts for each of the languages that you are going to want to work with, you store the language differences in resource files.

First, create a resource file called PageItems.resx. As before, this file contains two items only: Greeting and Question. Enter the same values you entered before. The other file to create is another resource file called PageItems.fi-FI.resx with the same keys as the other file. Figure 13-17 shows how both of these files should appear in the resource editor in Visual Studio 2008.

Once you have the resource files created in your project, the next step is to create a JavaScript file called ScriptLocalization.js that will use either of the resource files that you created. ...

Get Professional ASP.NET 3.5 AJAX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.