0

I want to change the language of my website. I defined two flags to change the language. I have two different tables for my native language and English. Here are the two functions shown below in my native language.

 [Route("BlogPost")]
        public ActionResult Blog(int Sayfa = 1)
        {
            ViewBag.Kimlik = db.Kimlik.SingleOrDefault();

            return View(db.Blog.Include("Kategori").OrderByDescending(x=>x.BlogId).ToPagedList(Sayfa,5));
        }
        [Route("BlogPost/{kategoriad}/{id:int}")]
        public ActionResult KategoriBlog(int id,int Sayfa=1)
        {
            ViewBag.Kimlik = db.Kimlik.SingleOrDefault();
            var b = db.Blog.Include("Kategori").OrderByDescending(x=>x.BlogId).Where(x => x.Kategori.KategoriId == id).ToPagedList(Sayfa,5);
            return View(b);
        } 

When I click the flag, I want to define a string like "en". It changes the relavent page like "/BlogPost/kategoriad/1" to "/en/BlogPost/kategoriad/1" and "www.websitename.com" to "websitename.com/en". How can I do that process to define a string when you change the language and call a relevant function. I hope you can help me.

S.N
  • 2,157
  • 3
  • 29
  • 78
  • 1
    Take a look here https://stackoverflow.com/a/12896687/177416 and here https://stackoverflow.com/questions/928053/asp-net-mvc-switch-language-how-to-implement – Alex May 26 '21 at 22:15
  • @Alex Where do I define a code which detects browser language. How can I implement other process which I mentioned in my post? – S.N May 26 '21 at 22:29
  • @Alex Is it possible to explain each process step by step if you don't mind? – S.N May 26 '21 at 22:50
  • Take a look at this: https://afana.me/archive/2011/01/14/aspnet-mvc-internationalization.aspx/ You may want to create a sample app and do this and then do it on your main project – Alex May 28 '21 at 21:42

0 Answers0