473,382 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

A question on ASP.net localization

Hi everyone...

I am creating a web app that will support english and french languages.

My code is fairly simple and it working fine. In my global.asax file I have
the
following code in the Application_BeginRequest event.

try
{
Thread.CurrentThread.CurrentCulture = new
CultureInfo(Request.UserLanguages[0]);
}
catch(Exception)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
}

I have a resource file for french and a resource file for english, and if
the browser langauge
is set to french, then french info is displayed, and if the browser
langauage is set to english,
then english is displayed. So far everything is perfectly.
My issue is, suppose the browser is set to Arabic, or Italian, or any other
langauge, I want to
default it to English. How do I do this ?
Nov 18 '05 #1
4 1104
Hi, JollyK,

It is the CurrentUICulture property on the Thread class that is taken in
consideration by the Resource Manager to look up culture-specific resources
at run time. If you replace CurrentCulture with CurrentUICulture in the code
you posted, and if everything else works, you should be set.

Greetings
Martin
"JollyK" <Jo****@email.com> wrote in message
news:em**************@tk2msftngp13.phx.gbl...
Hi everyone...

I am creating a web app that will support english and french languages.

My code is fairly simple and it working fine. In my global.asax file I have the
following code in the Application_BeginRequest event.

try
{
Thread.CurrentThread.CurrentCulture = new
CultureInfo(Request.UserLanguages[0]);
}
catch(Exception)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
}

I have a resource file for french and a resource file for english, and if
the browser langauge
is set to french, then french info is displayed, and if the browser
langauage is set to english,
then english is displayed. So far everything is perfectly.
My issue is, suppose the browser is set to Arabic, or Italian, or any other langauge, I want to
default it to English. How do I do this ?

Nov 18 '05 #2
this code will have problems because of asp.net thread agility. the same
thread is not necessarily used for a page process, so if a thread switch is
done, you will have the wrong culture.

you need to set the thread culture before any calls that need it (you should
also restore it, before the threads returned to the pool)

-- bruce (sqlwork.com)


"JollyK" <Jo****@email.com> wrote in message
news:em**************@tk2msftngp13.phx.gbl...
Hi everyone...

I am creating a web app that will support english and french languages.

My code is fairly simple and it working fine. In my global.asax file I have the
following code in the Application_BeginRequest event.

try
{
Thread.CurrentThread.CurrentCulture = new
CultureInfo(Request.UserLanguages[0]);
}
catch(Exception)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
}

I have a resource file for french and a resource file for english, and if
the browser langauge
is set to french, then french info is displayed, and if the browser
langauage is set to english,
then english is displayed. So far everything is perfectly.
My issue is, suppose the browser is set to Arabic, or Italian, or any other langauge, I want to
default it to English. How do I do this ?

Nov 18 '05 #3
Hi Bruce,
How about an example
"bruce barker" <no***********@safeco.com> wrote in message
news:#p**************@TK2MSFTNGP11.phx.gbl...
this code will have problems because of asp.net thread agility. the same
thread is not necessarily used for a page process, so if a thread switch is done, you will have the wrong culture.

you need to set the thread culture before any calls that need it (you should also restore it, before the threads returned to the pool)

-- bruce (sqlwork.com)


"JollyK" <Jo****@email.com> wrote in message
news:em**************@tk2msftngp13.phx.gbl...
Hi everyone...

I am creating a web app that will support english and french languages.

My code is fairly simple and it working fine. In my global.asax file I

have
the
following code in the Application_BeginRequest event.

try
{
Thread.CurrentThread.CurrentCulture = new
CultureInfo(Request.UserLanguages[0]);
}
catch(Exception)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
}

I have a resource file for french and a resource file for english, and if the browser langauge
is set to french, then french info is displayed, and if the browser
langauage is set to english,
then english is displayed. So far everything is perfectly.
My issue is, suppose the browser is set to Arabic, or Italian, or any

other
langauge, I want to
default it to English. How do I do this ?


Nov 18 '05 #4
Hi, bruce baker,

Could you prove your point with some documentation?

There is a tutorial that in fact shows how to set the CurrentUICulture in
the Application_BeginRequest handler:

http://msdn.microsoft.com/library/en...nd_asp_net.asp

I personally don't see a situation in which more than one thread could be
used in the execution of a Page class given the used model for the page
lifecycle.

Greetings
Martin
"bruce barker" <no***********@safeco.com> wrote in message
news:#p**************@TK2MSFTNGP11.phx.gbl...
this code will have problems because of asp.net thread agility. the same
thread is not necessarily used for a page process, so if a thread switch is done, you will have the wrong culture.

you need to set the thread culture before any calls that need it (you should also restore it, before the threads returned to the pool)

-- bruce (sqlwork.com)


"JollyK" <Jo****@email.com> wrote in message
news:em**************@tk2msftngp13.phx.gbl...
Hi everyone...

I am creating a web app that will support english and french languages.

My code is fairly simple and it working fine. In my global.asax file I

have
the
following code in the Application_BeginRequest event.

try
{
Thread.CurrentThread.CurrentCulture = new
CultureInfo(Request.UserLanguages[0]);
}
catch(Exception)
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
}

I have a resource file for french and a resource file for english, and if the browser langauge
is set to french, then french info is displayed, and if the browser
langauage is set to english,
then english is displayed. So far everything is perfectly.
My issue is, suppose the browser is set to Arabic, or Italian, or any

other
langauge, I want to
default it to English. How do I do this ?


Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Amin Schoeib | last post by:
Hi, I am a Postgres newbie who worked until now with Oracle. Now I want to know if it is possible (when yes the how?) in Postgresql To set dynamically the Localization? For example in Oracle you...
0
by: Amin Schoeib | last post by:
Hi, I am a Postgres newbie who worked until now with Oracle. Now I want to know if it is possible (when yes the how?) in Postgresql To set dynamically the Localization? For example in Oracle you...
6
by: Rental | last post by:
I'm having the sam problem as described below with the Localization toolkit. Does anyone know if there is a solution to this problem. --->When attempting to generate resource dlls with...
2
by: Julia | last post by:
Hi, We want to migrate out asp application to asp.net and take advantage on localization. I want to ask how it is advice to structure the site directory I am going to use resource only...
8
by: Olivier Matrot | last post by:
I encounter a problem with Localization features in ASP.NET 2.0. Is seems that the framework is not able to manage neutral cultures such as 'fr', or 'de'. Those are the culture sent by default from...
5
by: CMM | last post by:
I don't seem to "get" ASP.NET 2.0's Localization features. I've read up on everything... and of course, everything is explained in cursory softball terms- not any "real-world" usage way. I hope...
2
by: bruno | last post by:
I need to localize my ASP.NET app and I just used "Tools" --"generate local resources" command and everything works fine in my WebForms. Resource file name is: MyWebForm.aspx.resx under a subDir...
0
by: shapper | last post by:
Hello, Sometime ago I followed an article (I believe MSDN) related with localization in Asp.Net 2.0. To make pages localization I create a class named Localization: 1 Public Class...
3
by: Corey B | last post by:
I have an ASP.NET application that was built in ASP.NET v1.1. It has a SQL Server back end database. I have been asked to provide an estimate for the level of effort required to produce a Chinese...
3
by: Computer Guru | last post by:
I have a VB.NET 2005 application with several forms and a couple hundred "strings." I've been looking into all the localization improvements in VB.NET, and I can't seem to find anything that...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.