c# - Building a language switcher - 2 languages only - ASP.NET MVC -


ASP.NET MVC app is close to completion, it was decided that it requires language switcher. There will be only two languages: English and Japanese should be able to switch between them, but if none is selected, choose the default language of the browser.

I am thinking that what would be the best solution in this matter. / P>

First thought , route! That's why I change the paths for / {l} at the end of each path, and default l = "" . After that, in my base controller (it has been turned off by each controller), I see the l variable in the path. Each action gives a view based on the language.

I just wanted to be able to hook / ja-jp at the end of the URL, and it would show a scene in Japanese. It did not seem right correctly after that, I had real bad in my thoughts and hands, coded the links ... I was not able to output the helpful link first ... and the bad of the hand I used to codify them in habit, so, I have to re-code every link again - to hack the language variable at the end.

Second thought ... Okay, use jQuery to add language variable in all anchor's href it seems very clumsy and difficult in some situations where As far as necessary, HRS is hidden ... etc ... At this point I have decided that to do whatever he takes it. What is the best way to switch between 2 languages ​​without using resource files? I just want to choose between 2 ideas based on language.

Do I rewrite every link to use HTML Assistant and then working?

I think that one of the easiest and user-friendly methods To use a domain (actually a sub-domain), it is what language it speaks of. It does not need to change almost anything in HTML Assistant (those HTML.ActionLink) Works relatively well for it, and it can be clearly visible to the user to see that domain. They know what language it should be, and without making the URL too long, you only have to do something to work in the language switcher.

No matter what the approach is I'm strongly disappointed with the second idea, because you can not deny javascript (even 0.1%) to go to your Japanese web site, okay?


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -