Global resource vs. Local resource in ASP.NET Global resource vs. Local resource in ASP.NET asp.net asp.net

Global resource vs. Local resource in ASP.NET


I kept on looking for guidelines, and found this in MSDN:

Choosing Between Global and Local Resource Files

You can use any combination of globaland local resource files in the Webapplication. Generally, you addresources to a global resource filewhen you want to share the resourcesbetween pages. Resources in globalresource files are also strongly typedfor when you want to access the filesprogrammatically.

However, global resource files canbecome large, if you store alllocalized resources in them. Globalresource files can also be moredifficult to manage, if more than onedeveloper is working on differentpages but in a single resource file.

Local resource files make it easier tomanage resources for a single ASP.NETWeb page. But you cannot shareresources between pages. Additionally,you might create lots of localresource files, if you have many pagesthat must be localized into manylanguages. If sites are large withmany folders and languages, localresources can quickly expand thenumber of assemblies in theapplication domain.

When you make a change to a default resource file,either local or global, ASP.NETrecompiles the resources and restartsthe ASP.NET application. This canaffect the overall performance of yoursite. If you add satellite resourcefiles, it does not cause arecompilation of resources, but theASP.NET application will restart.

So it seems that it's really up to the programming team to weigh the pros and cons of each method and choose what's good for them.


Joe90 - I have to say that in my experience, I can't agree that managing lots of local resource files scattered throughout your whole project is easier than managing one, global resource file. There is nothing to stop repetition of the same translations again and again and they are very difficult to track down. Access to the Global resource file is very easy to co-ordinate within a team and multiple users can see at a glance whether their required translation has already been done.

I started off with exactly the same policy as Lea - i.e. start with a local resource file and then move this to a global resource file if it was referenced more than once. This soon became loads of hassle to manage and I've since moved to using global resource files every time now.

There don't seem to be any clear guidelines by Microsoft as to what the best practice is, or even, how the two methods are implemented so that we can hazard a guess!

I'm guessing the comparison/payoff is that local resource files only require a recompile of the file they relate to, whereas changing a global resource file seems to require a recompile of the whole web site - with an inherent loss of session state etc. so requires taking the site offline during the update to be safe.


I have a development team of at least 10 developers on a single product and we are using one global resx for each site.

The problem with merging this big resx file should in my opinion not be a problem.

If you have 10 developers who themselves set the language on the site, how do you get a uniform way to express themselves on the site? Developers often tend to be good at code and not the grammatical expression. (I am a developer myself.)

A language expert should edit resx file and lock it for the developers!