Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple resource files versus single resource file

This question is about the performance

I am working on MVC4 and I want to support multi-language views.

I am using one resourse file for each language like this:

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

and after specifying the culture, I do this in my views

@Multi.Name

However, I make breakpoints to check the value of @Multi and really it contains all the keys in my resources. Imagine all of them :P

My question is: would it perform better if I used a resource file for each view? Or will all the resources be loaded when I run my application even if I use multiple resource files for each view?

I am really not good at english, if you didn't understand my question, just ask me to clarify.

like image 626
user2208349 Avatar asked Nov 11 '13 16:11

user2208349


1 Answers

I know this is old thread, but I am also looking for the answer. Was single (and huge resource) file will effect the performance?.

After researching, I found this link and I thought to share with you (in case you are still looking).

Well, the short answer is NO, it will NOT affect the performance. However, it may cause problem when working in large team (where each of the programmer requires to modify the same resource file) and it can be troublesome to merge the changes.

Here is the guideline from 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.

I hope this can help someone who seeking the same answer.

Cheers, Sam

like image 104
Sam Avatar answered Oct 24 '22 15:10

Sam