Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult ChangeLanguage(String LanguageAbbrevation)
- {
- if (LanguageAbbrevation != null)
- {
- Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(LanguageAbbrevation);
- Thread.CurrentThread.CurrentUICulture = new CultureInfo(LanguageAbbrevation);
- }
- HttpCookie cookie = new HttpCookie("Language");
- cookie.Value = LanguageAbbrevation;
- Response.Cookies.Add(cookie);
- return RedirectToAction("Index","Home");
- }
- protected void Application_BeginRequest(object sender, EventArgs e)
- {
- HttpCookie cookie = HttpContext.Current.Request.Cookies["Language"];
- if (cookie != null && cookie.Value != null)
- {
- System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cookie.Value);
- System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(cookie.Value);
- }
- else
- {
- System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en");
- System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en");
- }
- }
- public ActionResult AboutUs()
- {
- HttpCookie cookie = HttpContext.Request.Cookies["Language"];
- var categoryList = context.SiteContents.Where(x => x.LanguageTB.CultureCode==cookie.Value).ToList();
- return View(categoryList);
- }
- public ActionResult AllAttorney()
- {
- HttpCookie cookie = HttpContext.Request.Cookies["Language"];
- var employeelist = context.Employees.Where(x => x.LanguageTB.CultureCode== mainLanguage.lb).ToList();
- return View(employeelist);
- }
- <ul class="list-unstyled list-inline">
- <li> <a href="@Url.Action("Change","Language",new { LanguageAbbrevation = "en" })">en</a></li>
- <li> <a href="@Url.Action("Change","Language",new { LanguageAbbrevation = "az" })">az</a></li>
- <li> <a href="@Url.Action("Change","Language",new { LanguageAbbrevation = "ru" })">ru</a></li>
- <li class="nav-item">
- <a href="@Url.Action("AllAttorney", "Home")">@RHome.MAttorney</a>
- </li>
- <li class="nav-item">
- <a href="@Url.Action("AboutUs", "Home")">@RHome.MAboutUs</a>
- </li>
- <li class="nav-item">
- <a href="@Url.Action("caseResult", "Home")">@RHome.MNews</a>
- </li>
- </ul>
- [Table("LanguageTB")]
- public partial class LanguageTB
- {
- public LanguageTB()
- {
- Articles = new HashSet<Article>();
- Employees = new HashSet<Employee>();
- SiteContents = new HashSet<SiteContent>();
- }
- [Key]
- public int LanguageId { get; set; }
- [StringLength(50)]
- public string CultureCode { get; set; }
- [StringLength(100)]
- public string CultureName { get; set; }
- public virtual ICollection<Article> Articles { get; set; }
- public virtual ICollection<Employee> Employees { get; set; }
- public virtual ICollection<SiteContent> SiteContents { get; set; }
- }
Add Comment
Please, Sign In to add comment