views:

351

answers:

2

There seems to be two different approaches. ASP.NET framework gives us an easy way to localize pages by putting UI strings in resources, like UserProfile.en.resx, UserProfile.fr.resx etc.

The other approach is to put all strings in separate tables in the database then use some custom mechanisms to retrieve them accodring to the currently active language/culture settings.

As much as I understand it, the database approach is more typical for big projects like maybe enterprise software. It also has a benefit that you can give an outside access to that database to maybe a translation firm. With resources it would be difficult.

On the other hand, retrieving all static strings from the database is an additional traffic and load overhead. I can't see any benefits for a relatively small web site to do that. "Small" meaning not traffic but the amount and complexity of pages.

I personally prefer using resources for my private projects. Is this an absolutely bad idea?

By the way, can I still use resources with ASP.NET MVC?

Any thoughts are appreciated.

EDIT: Just one answer, cannot believe that this question is of no interest to anyone. Noone wants to share their opinions?

A: 

i prefer saving all this info in a database instead of depending upon asp.net resource files.

what i have done is subclassed my common controls (like label) and override the render method. this method looks for current culture and sets the appropriate caption accordingly by looking up to my data structures

regarding performance when you save them in a database - this is what i do: in my application_start event, i simply load all my culture specific description into a custom object and cache it really long. this way i dont have to hit the database until my cache has expired or i force it to expire

so far we have never faced any problems with performance following this approach. having said all this - please note i am not saying that using resource files is a bad option either

but if given a choice to me, i would prefer the database approach instead of resource file approach

Raj
+1  A: 

Combine the two. You can write a custom resource provider which uses a database instead of a resource file so you don't have to do the heavy lifting of binding the text yourself (which is, lets face it, prone to error), you simply use ASP.NET's localisation functionality. MSDN has a good walkthrough by Michelle Leroux Bustamante

blowdart