简体   繁体   English

带有Razor的ASP.net MVC4中的本地化项目

[英]Localization project in ASP.net MVC4 with Razor

I have a project in MVC4 with Razor and I want it to be multilingual, I have a dropdownlist with several languages and I need the page to change when the user select an option in the dropdonlist, example: 我在MVC4中有一个带有Razor的项目,并且希望它是多语言的,我有一个包含多种语言的下拉列表,并且当用户在dropdonlist中选择一个选项时,需要更改页面,例如:

  • default option "en" - default url "/myproject.com" 默认选项“ en”-默认网址“ /myproject.com”
  • option "es" - url "/myproject.com/es/miproyecto" 选项“ es”-网址“ /myproject.com/es/miproyecto”
  • option "it" - url "/myproject.com/it/mioprogetto" 选项“它”-网址“ /myproject.com/it/mioprogetto”

I know I must use routes and resources, but how? 我知道我必须使用路由和资源,但是如何使用?

here Scott Hanselman http://www.hanselman.com/blog/GlobalizationInternationalizationAndLocalizationInASPNETMVC3JavaScriptAndJQueryPart1.aspx explaining it very well. 在这里Scott Hanselman http://www.hanselman.com/blog/GlobalizationInternationalizationAndLocalizationInASPNETMVC3JavaScriptAndJQueryPart1.aspx对此进行了很好的解释。

But be careful on multilingual websites you also have to test your JavaScript for the other languages. 但是在多语言网站上要小心,您还必须测试其他语言的JavaScript。

I would use only one URL and use Resource Strings in your project for the different languages. 我将只使用一个URL,并在您的项目中为不同的语言使用资源字符串。 Because this is better/easier for search engines like Google to find your Information and show them for one URL. 因为这对于Google这样的搜索引擎来说更好/更容易找到您的信息并显示一个URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM