Thanks for everybody's informative inputs.
Hi Thomas,
First, I can also confirm that we can reuse asp.net page's codebehind file
for multi aspx pages. In fact, the codebehind file(page class) are all
compiled into assemblies. So the one we reuse is the page class in the
assembly rather than the codebehind file.(Codebehind is used for VS.NET at
design-time)
Also, as other members have said, we are more recommeded to make use of the
.net application's buildin globalization/localization features rather than
provide multi pages for different cultures. As for the two new questions
you mentioned, here is some of my understandings:
========================
By the way where do you check for your session[languageid]? In Page_Load
event?
=======================
In asp.net , the Request object has a UserLanguages collection which
contains the client browser's favored languages and we can use the
CultureInfo class under the System.Globalization namespace to create a
CultureInfo instance through one of the language item, for example:
#setting the current thread's culture info
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(Request.UserLang uages[0]);
#Using the CurrentCulture Property
http://msdn.microsoft.com/library/en...gcurrentcultur
eproperty.asp?frame=true
Thus, we can put the above code in your asp.net web application's global
object's BeginRequest event, such as :
protected void Application_BeginRequest(Object sender, EventArgs e)
{
System.Web.HttpApplication app = sender as System.Web.HttpApplication;
System.Web.HttpRequest req = app.Request;
System.Globalization.CultureInfo ci =
System.Globalization.CultureInfo.CreateSpecificCul ture(req.UserLanguages[0])
;
System.Threading.Thread.CurrentThread.CurrentCultu re = ci;
}
then, in each page's Load or Init event, you can retrieve the current
thread's culture info and retrieve the correct localized resources to
decorate your page UI
=======================
Are there any good reasons why you should store your translated text in
resource files instead of a db?
=========================
use resources files can help use embeded the resource into assembly so that
we can put different resources (for different culture) in different
assemlblies which are located in a hierarchical structure in the
application's bin folde such as
/bin
mainresource.dll
/en-US
/zh-CN
/fr-FR
Also, the asp.net application provide shadow copy for the assemblies it
use, so that we can update the assemly whenever we have new versions. I
think this is much flexible than use DB storage.
Just some of my opinions. Hope helps. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)