C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

Localizing The Application


Posted Date: 13 Mar 2004    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: SivaMember Level: Gold    
Rating: 1 out of 5Points: 5



Many classes in the .NET Framework -- and, by extension, in ASP.NET -- are culture-aware. To access this awareness, you need to create a CultureInfo object to represent the current culture and associate it with the running thread's CurrentCulture property. Once this link has been made, common functions such as String.Format and DateTime's ToShortDateString will adjust according to the culture formatting.

ASP.NET must look at the Accept-Language header of the HTTP request to determine a user's culture request. ASP.NET will expose this header as a string array under the UserLanguages property of the Request object.

Adding some code to the Global.asax file's Application_BeginRequest event will allow you to create the CultureInfo object for the correct language (see Figure 5). Once you have created the CultureInfo object for the user's primary language, it will need to be associated to the current thread processing the request.

Getting ASP.NET formatting data according to each user's culture preference might be just the first step in making your application span the global community. But in many cases, it might be the only step needed.


Imports System.Threading
Imports System.Globalization

Public Class Global
Inherits System.Web.HttpApplication

Sub Application_BeginRequest(ByVal sender As Object, _
ByVal e As EventArgs)
Try
If Request.UserLanguages.Length > 0 Then
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture_
(Request.UserLanguages(0))

End If
Catch
'Don't error if CreateSpecificCulture fails
End Try
End Sub
End Class


Siva




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Adding Row Numbers
Previous Resource: MailMessage Class - Properties
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use