Reputation: 3297
I'm developing bilingual ASP.NET Application and I want to know hat is the best way to store UICulture and Culture values all over the application?
Update: I want to make the same ASPX form to be bilingual pages, what I've got an answers till now is to make a separate page and make it accessible by sub-domain, what I'm really doing now is using Session, but i want to now what is the best practice to user Resource file to make the page bilingual without creating another copy of it.
Upvotes: 2
Views: 830
Reputation: 56456
As often, it depends on your particular use case.
Most often however you'd probably want to have a different URL for each page and language in order to have it indexed properly by search engines. For example URL's like:
I prefer the first 2 options.
Optionally, you could redirect the user based on their browser language when they first arrive on your site (but please make sure that the user still can browse the other languages).
Update: This doesn't mean you'll have to make as many versions of your site as you have languages.
If you have a subdomain for each language:
InitializeCulture
method (you may use a base class for all pages in order to keep it DRY)InitializeCulture
methodIf you decide not to use subdomains but include the culture name in your URL, you may use URL-rewriting to point to the same page from each URL.
Some code to get you started:
protected override void InitializeCulture() {
// Identify the culture and replace the hardcoded values below
// (Use Request.Url.xxx for example)
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en", false);
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", false);
base.InitializeCulture();
}
Upvotes: 3
Reputation: 2534
The best practice is to create sub-domains\separate site for each language with its own separate IIS website. This is particularly true for Asian languages where you will need double byte.
You will see this practice all over in yahoo, google, etc.:
Upvotes: -1
Reputation: 3704
You can always use URL re-writing to store the chosen cultural preference of the user. Not particularly sure how this is achieved in ASP.Net, but it's easy using the routing table in MVC.
To elucidate, your url would look something like this: http://example.org/en-gb/Action As a solution, this removes the overhead of sessions, the possibility that someone has turned cookies off in the browser, and the unsightly QueryString that gets generated.
I'll try and get back with an example of how to do the url re-writing.
Upvotes: -1