home *** CD-ROM | disk | FTP | other *** search
- <%@ Register TagPrefix="Acme" TagName="SourceRef" Src="/quickstart/util/SrcRef.aspx"%>
-
- <!-- #include virtual="/quickstart/aspplus/include/header.inc" -->
-
- <h4>Localizing ASP+ Applications</h4>
-
- <div class="indent" style="font-family:Verdana; font-size:8pt;">
- <b> <img align="middle" src="/quickstart/images/bullet.gif"> </b>
- <a class="toc2" target="content" href="#copy">Copy and Translate</a><br>
- <b> <img align="middle" src="/quickstart/images/bullet.gif"> </b>
- <a class="toc2" target="content" href="#embed">Common Components</a><br>
- </div>
-
- <p>
- <hr>
-
-
- <!--BEGIN SECTION-->
- <a name="copy">
- <span class="subhead">Copy and Translate</span>
- <p>
-
- The easiest way to localize web pages is usually
- to create a copy and translate it to the target language.
- This works fine for static content, which does not require
- a lot of maintenance. To support this model for ASP+ pages
- the <b>Culture</b> attribute can be set on the
- Page directive. All locale-dependent methods will pick
- up the value of the Culture attribute.
- <p>
- The following sample shows this in three independent,
- localized versions of a page.
- On each page the Culture property is set, which determines
- the format of the date:
-
- <div class="code"><pre>
- <%@Page Culture="de" Language="C#" %>
- ...
- <%=DateTime.Now.Format("f", null)%>
- </pre></div>
- <p>
-
- <table>
- <tr>
- <td>
- <Acme:SourceRef
- RunSample="/quickstart/aspplus/samples/localize/localize1/news-en-us.aspx"
- ViewSource="/quickstart/aspplus/samples/localize/localize1/news-en-us.src"
- Icon="/quickstart/aspplus/samples/localize/flags/en-us.jpg"
- Caption="news-en-us.aspx"
- runat="server" />
-
- </td>
- <td>
- <Acme:SourceRef
- RunSample="/quickstart/aspplus/samples/localize/localize1/news-de.aspx"
- ViewSource="/quickstart/aspplus/samples/localize/localize1/news-de.src"
- Icon="/quickstart/aspplus/samples/localize/flags/de.jpg"
- Caption="news-de.aspx"
- runat="server" />
- </td>
- <td>
- <Acme:SourceRef
- RunSample="/quickstart/aspplus/samples/localize/localize1/news-ja.aspx"
- ViewSource="/quickstart/aspplus/samples/localize/localize1/news-ja.src"
- Icon="/quickstart/aspplus/samples/localize/flags/ja.jpg"
- Caption="news-ja.aspx"
- runat="server" />
- </td>
- </tr>
- </table>
-
-
-
-
- <!--BEGIN SECTION-->
- <br>
- <a name="embed">
- <br>
- <span class="subhead">Localizing and Embedded Controls</span>
- <p>
-
- An improvement over the simple copy and translate approach is to
- use controls, which pick up the culture of the main page. In this sample
- the image of the flag and the search bar are controls. Depending
- on the culture of the hosting page they render different content.
- To support this the <b>UICulture</b> attribute was also added to each page:
- <div class="code"><pre>
- <%@Page Culture="de" UICulture="de" Language="C#" %>
- </pre></div>
-
- <p>
- The flag control (flag.aspc) for example just uses the culture name to build the
- src attribute of an <img> tag:
- <div class="code"><pre>
- <%@Import Namespace="System.Globalization"%>
-
- <script runat="Server" Language="C#">
- override protected void PreRender()
- {
- FlagImage.Src = "../flags/" + CultureInfo.CurrentCulture + ".jpg";
- FlagImage.Alt = CultureInfo.CurrentCulture.NativeName;
- }
- </script>
-
- <img runat="server" id="FlagImage" />
- </pre></div>
- <p>
-
- The search control (search.aspc) uses a switch-statement to initialize the
- values of a label and a textbox, but the culture name could also be the
- parameter for a database query:
- <div class="code"><xmp>
- void LocalizeSearchText()
- {
- switch(String.Intern(CultureInfo.CurrentUICulture.Name))
- {
- case "en-us":
- SearchText.Text = "Clinton";
- SearchButton.Text = "Search";
- break;
- case "de":
- ...
- case "ja":
- ...
- default:
- SearchButton.Text = "Search";
- }
- }
- </xmp></div>
-
-
- <table>
- <tr>
- <td>
- <Acme:SourceRef
- RunSample="/quickstart/aspplus/samples/localize/localize2/news-en-us.aspx"
- ViewSource="/quickstart/aspplus/samples/localize/localize2/news-en-us.src"
- Icon="/quickstart/aspplus/samples/localize/flags/en-us.jpg"
- Caption="news-en-us.aspx"
- runat="server" />
-
- </td>
- <td>
- <Acme:SourceRef
- RunSample="/quickstart/aspplus/samples/localize/localize2/news-de.aspx"
- ViewSource="/quickstart/aspplus/samples/localize/localize2/news-de.src"
- Icon="/quickstart/aspplus/samples/localize/flags/de.jpg"
- Caption="news-de.aspx"
- runat="server" />
- </td>
- <td>
- <Acme:SourceRef
- RunSample="/quickstart/aspplus/samples/localize/localize2/news-ja.aspx"
- ViewSource="/quickstart/aspplus/samples/localize/localize2/news-ja.src"
- Icon="/quickstart/aspplus/samples/localize/flags/ja.jpg"
- Caption="news-ja.aspx"
- runat="server" />
- </td>
- </tr>
- </table>
-
-
- <h4>Section Summary</h4>
- <ol>
- <li>ASP+ pages support Culture and UICulture attributes to support independent localized pages.
- <li>Controls on pages will pick the cultures of the page and can render culture-dependent content.
- </ol>
-
- <!-- #include virtual="/quickstart/aspplus/include/footer.inc" -->
-
-
-
-
-
-