Guest User

Untitled

a guest
Dec 8th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. public ActionResult ChangeLanguage(String LanguageAbbrevation)
  2. {
  3. if (LanguageAbbrevation != null)
  4. {
  5. Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(LanguageAbbrevation);
  6. Thread.CurrentThread.CurrentUICulture = new CultureInfo(LanguageAbbrevation);
  7.  
  8. }
  9. HttpCookie cookie = new HttpCookie("Language");
  10. cookie.Value = LanguageAbbrevation;
  11. Response.Cookies.Add(cookie);
  12. return RedirectToAction("Index","Home");
  13.  
  14. }
  15.  
  16. protected void Application_BeginRequest(object sender, EventArgs e)
  17. {
  18. HttpCookie cookie = HttpContext.Current.Request.Cookies["Language"];
  19. if (cookie != null && cookie.Value != null)
  20. {
  21. System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cookie.Value);
  22. System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(cookie.Value);
  23. }
  24.  
  25. else
  26. {
  27. System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en");
  28. System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en");
  29.  
  30. }
  31. }
  32.  
  33. public ActionResult AboutUs()
  34. {
  35. HttpCookie cookie = HttpContext.Request.Cookies["Language"];
  36. var categoryList = context.SiteContents.Where(x => x.LanguageTB.CultureCode==cookie.Value).ToList();
  37. return View(categoryList);
  38. }
  39.  
  40. public ActionResult AllAttorney()
  41. {
  42. HttpCookie cookie = HttpContext.Request.Cookies["Language"];
  43. var employeelist = context.Employees.Where(x => x.LanguageTB.CultureCode== mainLanguage.lb).ToList();
  44. return View(employeelist);
  45. }
  46.  
  47. <ul class="list-unstyled list-inline">
  48. <li> <a href="@Url.Action("Change","Language",new { LanguageAbbrevation = "en" })">en</a></li>
  49. <li> <a href="@Url.Action("Change","Language",new { LanguageAbbrevation = "az" })">az</a></li>
  50. <li> <a href="@Url.Action("Change","Language",new { LanguageAbbrevation = "ru" })">ru</a></li>
  51. <li class="nav-item">
  52. <a href="@Url.Action("AllAttorney", "Home")">@RHome.MAttorney</a>
  53. </li>
  54. <li class="nav-item">
  55. <a href="@Url.Action("AboutUs", "Home")">@RHome.MAboutUs</a>
  56. </li>
  57. <li class="nav-item">
  58. <a href="@Url.Action("caseResult", "Home")">@RHome.MNews</a>
  59. </li>
  60. </ul>
  61.  
  62. [Table("LanguageTB")]
  63. public partial class LanguageTB
  64. {
  65. public LanguageTB()
  66. {
  67. Articles = new HashSet<Article>();
  68. Employees = new HashSet<Employee>();
  69. SiteContents = new HashSet<SiteContent>();
  70. }
  71.  
  72. [Key]
  73. public int LanguageId { get; set; }
  74.  
  75. [StringLength(50)]
  76. public string CultureCode { get; set; }
  77.  
  78. [StringLength(100)]
  79. public string CultureName { get; set; }
  80.  
  81. public virtual ICollection<Article> Articles { get; set; }
  82. public virtual ICollection<Employee> Employees { get; set; }
  83. public virtual ICollection<SiteContent> SiteContents { get; set; }
  84. }
Add Comment
Please, Sign In to add comment