Culture

S

shapper

Hello,

I am working on a multilanguage Asp.Net 2.0 web site.

I need to do the following:
1. Set a default culture in Web.Config File.
2. Create a function which changes culture when pressed.
Remember the choosen culture next time the visitor comes to the web
site.
3. Retrieve the current culture.

How can I do this?

Thanks,
Miguel
 
C

Cowboy \(Gregory A. Beamer\)

Setting default culture in web.config (question 1)
<globalization culture="auto:en-US" uiCulture="auto:en"/>

Then, create resource files in theApp_GlobalResources section. For mine, one
example, I have:

Address.resx - english (default)
Address.es.resx - spanish
Address.fr.resx - french

To set labels to different languages, you do it like this:
<asp:Label ID="NoDataLabel" runat="server" Text="<%$ Resources:Manage,
EmptyDataTemplate %>">

Changing Culture: First, let the user default to his native browser choice,
which is what globalization will do natively. If a user has not chosen a
different language, leave it unset.

To change culture, you simply set the culture to the main thread. Grab the
CurrentThread and set the culture on that thread.

Does this cover your questions?

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
 
S

shapper

Hi,

Got a litle bit lost.

1. When I set the culture in web.config globalization doesn't that mean
that it everytime he visits the web site he will have those values?
What does the "auto" before "en-US"

2. To store the user choosen culture I was thinking in using the
profile as follows:

<anonymousIdentification enabled="true" />
<profile>
<properties>
<add name="UserCulture" defaultValue="en-US" />
<add name="UserUICulture" defaultValue="en"/>
</properties>
</profile>

Then I just save the user culture values to profile properties
UserCulture or UserUICulture.
In Global.asax on Application_Start I set the Culture and UICulture
equal to these profile values.

What do you think?

Thanks,

Miguel

P.S: I am full aware of the resources part and my project is allready
prepared for it.
 
C

Cowboy \(Gregory A. Beamer\)

In globalization, the default language is set. Everything will have that
language unless a culture is chosen. you can use the profile as you are
stating. It is realtively easy to pull the Profile object at runtime.

Here is a blog link that contains a video on profiles and localization. It
should help a lot:
http://weblogs.asp.net/scottgu/archive/2006/02/26/Great-ASP.NET-2.0-Tutorial-Videos-Online.aspx

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top