ASP.NET: is it better to store localized user interface text in resources or in a database?

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

Another approach is to put all the rows in separate tables in the database, and then use some custom mechanisms to retrieve them according to the current active language / culture settings.

As far as I understand, the approach to the database is more typical for large projects, such as, possibly, corporate software. It also has the advantage that you can provide external access to this database, possibly to a translation company. With resources it will be difficult.

On the other hand, getting all the static rows from the database is additional traffic and load. I see no advantages for a relatively small website for this. β€œSmall” does not mean traffic, but the number and complexity of pages.

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

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

Any thoughts are appreciated.

EDIT: Just one answer, I can’t believe that this question is of no interest to anyone. Nobody wants to share their opinions?

+6
resources localization multilingual
source share
2 answers

Combine the two. You can write a custom resource provider that uses a database instead of a resource file, so you don't have to do the hard work of linking the text yourself (which, let's face it, error prone), you just use ASP. NET MSDN has a good passing Michelle Leroux Bustamante

+3
source share

I prefer to store all this information in a database rather than depending on asp.net resource files.

what I did is a subclass of my common controls (like label) and overrides the rendering method. this method searches for the current culture and sets the corresponding header accordingly, looking through my data structures.

regarding performance when saving them to the database, this is what I do: in my application_start application I just load all my specific description into my own object and cache it for a very long time. thus, I should not hit the database before my cache expires, or I force it to expire

so far, we have never encountered any performance issues after this approach. having said all this - note, I'm not saying that using resource files is a bad option either

but if given a choice, I would prefer a database approach instead of a file file approach

+2
source share

All Articles