views:

59

answers:

2

Is there any way I can restrict my web application to certain cultures? So that .Net determines culture automatically, but the choice is restricted to these cultures.

For example, I would like to support only 'en-us' and 'it', so all other 'en' language clients will automatically be assigned 'en-us' culture.

UPDATE. I know how to set the thread culture, and I know how to determine the clients culture and then set the culture based on the clients 'base' culture (like set 'en' for all clients with 'en-xx' culture. I just want to do it properly.

Basically, I want to know how to limit the scope of cultures that is used to determine the culture when using culture="auto".

A: 

you can get the ip of the client and use a web service to check his country then the country will return from this webservice so if his language is en you can assign him to english culture of your application

peacmaker
I already know the culture from the "accepted languages" string, but I don't want to go through 10 variations of English, since asp.net can just assign 'en' to all clients automatically.
HeavyWave
+1  A: 

You can set EN culture as a default one providing locales for more specific ones, like en-uk, en-us, etc. only if needed.

That won't help for other cases of subcultures. But is there a need for these cases?

Update.

I also found full resource fallback sequence here at Rick Strahl's blog (look for Resource Fallback header:

The full sequence for resource lookups is:

  1. Specific locale lookup (en-US)
  2. Generic Language lookup (en)
  3. Invariant

So not only you can provide default resource, you can specify default resource for generic language.

terR0Q
If that's the case I don't even have to worry about anything. Awesome. Thanks.
HeavyWave