简体   繁体   English

ASP.NET MVC应用程序中的国际化

[英]Internationalization in ASP.NET MVC application

I'm going to develop an ASP.NET MVC web-app and I'm new to this framework. 我将开发一个ASP.NET MVC网络应用程序,并且对这个框架还是陌生的。 I usually develop web application on Java platform using Spring MVC as web framework. 我通常使用Spring MVC作为Web框架在Java平台上开发Web应用程序。

I need to implement internationalization in my new application but I can't find a standard approach to achieve this using ASP.NET MVC. 我需要在新应用程序中实现国际化,但是我找不到使用ASP.NET MVC实现此目标的标准方法。

In Spring I usually have several properties files for all the languages supported: messages_en.properties , messages_it.properties , etc. and I use a key-value approach to access the right message in the file: 在Spring中,我通常具有几个支持所有语言的properties文件: messages_en.propertiesmessages_it.properties等,并且我使用键值方法访问文件中的正确消息:

mainPage.title=The title # in messages_en.properties

mainPage.title=Il titolo # in messages_it.properties

Is there something similar in .NET platform? .NET平台中是否有类似内容? Or is there any other "standard" way to implement i18n? 还是还有其他“标准”方式来实现i18n?

You can achieve this with Resources. 您可以使用参考资料来实现。 Its the same simple key => value approach as in Spring, where you have a Resource File for each language. 它与Spring中的简单键=>值方法相同,在Spring中,每种语言都有一个资源文件。

ASP.NET uses Resource files to store various strings etc.... and each resource file can contain different language versions accessed using a key, similar to how you work now. ASP.NET使用资源文件存储各种字符串等。每个资源文件可以包含使用键访问的不同语言版本,类似于您现在的工作方式。

I would advise reading this blog which explains in good detail how to implement this across models, views and controllers: 我建议阅读此博客,该博客详细解释了如何在模型,视图和控制器之间实现这一点:

http://afana.me/post/aspnet-mvc-internationalization.aspx http://afana.me/post/aspnet-mvc-internationalization.aspx

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

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