Introduced
Declarative resource expressions enable your application to use multiple languages without having to manually write code to retrieve resources and replace them in the page. You can define resource substitution simply by using the newly provided expression syntax in ASP.net 2.0. ASP.net 2.0 supports the standard RESX file format for automatic Run-time resource retrieval.
The essential
1. Culture-Determines how various data types are organized, such as numbers and dates; UICulture-determines which localized resource to use, and which language is used. Set in the @page Directive of a page or in the <system.web><globalization> element of a configuration file (in addition, you can set property requestencoding,responseencoding within that element. fileencoding). Culture= "en-us" and culture= "auto:en-us" is the difference is that the latter will automatically match the first, can not automatically match the use of en-US
2. HTTP allows browsers to send a list of preferred languages to a WEB server using the Accept Language (accept-language) HTTP request header field. Selecting Tools in IE-Internet options-languages
3, Web.sitemap when the application localization <siteMap> the property enablelocalization= "true". Accessing Global resources: $Resources: Global resource Name, key in resource, default value, or resourcekey= "key in Web.sitemap.resx file"
4. GetGlobalResourceObject () and GetLocalResourceObject () in the process of programming
5, programming settings culture and UICulture please rewrite initializeculture (), to Thread.CurrentThread.CurrentCulture and Thread.CurrentThread.CurrentUICulture to set
6. Access to global resources: $ Resources: Global resource Name, key in resource, explicit access to local resource: $ resources:key. Attribute; implicit access to local resources: meta:resourcekey= "key".
Example
Localized testing
Localization/test.aspx
<%@ Page language= "C #" masterpagefile= "~/site.master" autoeventwireup= "true" codefile= "Test.aspx.cs" inherits= " Localization_test "title=" localized test "culture=" en-us "uiculture=" en-US "meta:resourcekey=" Title "%> <asp:content "Content1" contentplaceholderid= "ContentPlaceHolder1" runat= "Server" > <p> current language: <asp:label id= "LBLCU Rrentculture "runat=" Server "/> </p> <p> Current time: <%=datetime.now%> </p> <p>
; Implicit: <asp:label id= "LBL" runat= "Server" meta:resourcekey= "LBL"/></p> <p> Explicit: <asp:label Id= "LBL2" runat= "Server" text= "<%$ resources:lbl. Text%> "tooltip=" <%$ resources:lbl. ToolTip%> "/> </p> <p> Global: <asp:label id=" Lbl3 "runat=" Server "text=" <%$ resources:my
Global,globaltext%> "/> </p> <p> Encoding (Global Resources): <asp:label id=" LBL4 "runat=" Server "/> </p> <p> Encoding Mode (local resources): <asP:label id= "LBL5" runat= "server"/> </p> <p> Localize control mode (the Label control to the client resolves to <span> loca Lize to the client is parsed into the text it contains): <asp:localize id= "AboutUs" runat= "Server" meta:resourcekey= "AboutUs" ></asp:
localize> </p> <p> <a href= "? currentculture=zh-cn" > Chinese </a> <a href= "? currentculture=en-us" > English </a> </p> <p> Note: <br/> Culture-determine how various data types are organized , such as numbers and dates <br/> UICulture-determines which localized resource to use, which language </p> </asp:Content>