You will need to set this information via a cookie (which can be toggled by a setting on your page).
public ActionResult SetCulture(string culture) //culture is something like en-US, you can validate it ahead of time.
{
HttpCookie cookie = Request.Cookies["currentCulture"];
if (cookie != null)
cookie.Value = culture; // update cookie value
else //create the cookie here
{
cookie = new HttpCookie("currentCulture");
cookie.Value = culture;
cookie.Expires = DateTime.Now.AddYears(1);
}
Response.Cookies.Add(cookie);
return Redirect(Request.UrlReferrer.ToString()); //send them back to the site they were at (in a translated form).
}
To determine the culture on the server side, just read the cookie when you execute an action.
protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state)
{
HttpCookie cultureCookie = Request.Cookies["currentCulture"];
string cultureName = cultureCookie== null ? "en-US" : cultureCookie.Value;
if (cultureCookie != null)
cultureName = cultureCookie.Value;
// Modify current thread's cultures
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cultureName);
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
return base.BeginExecuteCore(callback, state);
}