微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – 多个资源文件与单个资源文件

这个问题与性能有关

我正在研究MVC4,我想支持多语言视图.

我正在为每种语言使用一个resourse文件,如下所示:

Multi.resx For English as default
Multi.ar.resx for arabic 
Multi.fr.resx for Frensh

在指定文化之后,我在我的观点中这样做

@Multi.Name

但是,我创建了断点来检查@Multi的值,它实际上包含了我资源中的所有键.想象一下所有人:P

我的问题是:如果我为每个视图使用资源文件,它会表现得更好吗?或者,即使我为每个视图使用多个资源文件,在运行我的应用程序时是否会加载所有资源?

我真的不擅长英语,如果你不理解我的问题,请让我澄清一下.

解决方法

我知道这是旧线程,但我也在寻找答案.单个(和巨大的资源)文件会影响性能吗?

经过研究,我发现这个link,我想与你分享(如果你还在寻找).

嗯,简短的答案是否定的,它不会影响性能.但是,在大型团队中工作时可能会出现问题(每个程序员都需要修改相同的资源文件),并且合并更改会很麻烦.

以下是MSDN的指南:

Choosing Between Global and Local Resource Files

You can use any combination of global and local resource files in the Web application. Generally,you add resources to a global resource file when you want to share the resources between pages. Resources in global resource files are also strongly typed for when you want to access the files programmatically.

However,global resource files can become large,if you store all localized resources in them. Global resource files can also be more difficult to manage,if more than one developer is working on different pages but in a single resource file.

Local resource files make it easier to manage resources for a single ASP.NET Web page. But you cannot share resources between pages. Additionally,you might create lots of local resource files,if you have many pages that must be localized into many languages. If sites are large with many folders and languages,local resources can quickly expand the number of assemblies in the application domain.

When you make a change to a default resource file,either local or global,ASP.NET recompiles the resources and restarts the ASP.NET application. This can affect the overall performance of your site. If you add satellite resource files,it does not cause a recompilation of resources,but the ASP.NET application will restart.

我希望这可以帮助那些寻求相同答案的人.

干杯,山姆

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐