13.7. Script Localization with Static Files

When working with the localization of your ASP.NET AJAX applications, another important aspect of localization is in how the scripts themselves are localized. For instance, if alerts and other items in your scripts require localization, you can perform localization to make a script for each language or culture that you are working with to get your ASP.NET page to work with the correct script based upon the end user's culture setting.

To show an example of this in action, Listing 13-15 provides a simple ASP.NET application that makes use of server-side JavaScript files.

Example 13-15. Localizing client-side JavaScript files
<%@ Page Language="C#" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Script Localization</title>

    <script type="text/javascript">

        function pageLoad() {

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"
                <asp:ScriptReference Path="~/Scripts/ScriptLocalization.js"
                 ResourceUICultures="fi-FI" />
        <span id="Label1"></span><br />
        <span id="Label2"></span>

This page is quite simple in that only two <span> elements are populated by a script (shown shortly) that contains the function populateItems(). Since you are going to want your application to be localized based on the end user's culture setting in their ...

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.