人生是一场不能存盘的RPG,我只能尽量多搞几个Screenshot

May 30, 2006

webcast_How do I Video Series_Localization

Filed under: ASP.NET

How do I? Video Series : Localization (hilo_localization_final.wmv)
http://asp.net/default.aspx?tabindex=4&tabid=3000
http://asp.net/learn/howdoi/default.aspx?tabid=63

0. Resource 语法
显式: <%$ Resources:[filename prefix,]resource-key %>

隐式: <asp:Label ID=”Label1″ runat=”server” meta:resourcekey=”resource-key-prefix” />

1. 使用Local resource

可以使用菜单Tools->Generate Local Resource来生成local resource.
foo.aspx will refer to the /App_LocalResources/foo.aspx.resx

Create a special folder named “App_LocalResources”.
Create a resource file named “Default.aspx.resx” in it.
Create a resource file named “Default.aspx.fr.resx” in it.

3. Using the resource in the control
<asp:Button ID=”Button1″ runat=”server” Text=”Button” meta:resourceKey=”Button1″/>

4. Set culture for the page
<%@Page … UICulture=”auto”>

在IE中可以设置 default language,从而进行测试

5. 使用Global resource
所有的page, user-control都可以访问
Create a special folder named “App_GlobalResources”.
Create a resource file named “Resource.resx” in it.
Create a resource file named “Resource.fr.resx” in it.

6. 设置Control.Expressions 属性
Sample1:
Bindable properties 设为 Text
Expression Type 设为 Resource
Expression properties 的ClassKey 设为 Resource
Expression properties 的ResourceKey 设为 “资源名称”
Sample2:
Bindable properties 设为 BackColor
Expression Type 设为 Resource
Expression properties 的ClassKey 设为 Resource
Expression properties 的ResourceKey 设为 “资源名称”

7. 通过代码设置Culture

using System.Threading;
using System.Globalization;

protected override InitializeCulture()
{
string lang = Resuest(” “);

Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
Thread.CurrentThread.CurrentCulture = new CultureInfo.CreateSpecificCulture(lang);
}

参考

ASP.NET 2.0 Localization Features: A Fresh Approach to Localizing Web Applications

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/asp2local.asp

Comments »

The URI to TrackBack this entry is: http://recordsome.blogsome.com/2006/05/30/webcast_how-do-i-video-series_localization/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.






















Get free blog up and running in minutes with Blogsome
Theme designed by Hadley Wickham