The simplest answer is that you need to create the controller that you are referring to.
public class LanguageController : Controller
{
public ActionResult SetLanguage(string name)
{
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(name);
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
HttpContext.Current.Session["culture"] = name;
return RedirectToAction("Index", "Home");
}
}
Then, in your opinion:
<a href="@Url.Action("SetLanguage", "Language", new { @name = "pl" })">Polski</a>
<a href="@Url.Action("SetLanguage", "Language", new { @name = "en" })">English</a>
You might want to save user data in a session or similar.
EDIT:
, Application_BeginRequest global.asax.
protected void Application_BeginRequest(Object sender, EventArgs e)
{
var name = HttpContext.Current.Session["culture"] as string;
if (string.IsNullOrEmpty(name))
{
return;
}
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(name);
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;
}
EDIT:
cookie SetLanguage:
var cookie = new HttpCookie("_culture", name);
cookie.Expires = DateTime.Today.AddYears(1);
Response.SetCookie(cookie);
cookie Application_BeginRequest:
var cookie = HttpContext.Current.Request.Cookies["_culture"];
var name = cookie != null ? cookie.Value : null;