.resx vs database vs custom solution for providing Localization/Globalization .resx vs database vs custom solution for providing Localization/Globalization asp.net asp.net

.resx vs database vs custom solution for providing Localization/Globalization


Rick Strahl (An MS MVP) has a great tool kit for managing localization via the DB - offer the ability to update and modify on demand through a controlled environment and does much of the heavy lifting for you. Histoolkit offer the following features:

Data Driven Localization Resource Provider

  • Database driven Localization lets you store resources in a SQL Server database.
  • Interactive Web based Resource Adminstration provides a live Web based adminstration for that can edit and update resources while the app is running
  • Resource Editing Control associates icons with each localizable control and allows jumping directly to the administration form with the current resource id and locale selected.
  • Resx Import and Export lets you import existing Resx resources, interactively edit them with the data driven provider, then export them back out as Resx resources.
  • Localization Utilities like a JavaScript Resource Handler, functions to embed localized script values and much more.

He also summarises the issues very well here (Ive pasted some good bits here - not my own work!)

To Resx or not to Resx

The default resource storage mechanism in .NETuses Resx based resources. Resx refers to the file extension of XMLfiles that serve as the raw input for resources that are native to.NET. Although XML is the input storage format that you see in VisualStudio and the .Resx files, the final resource format is a binaryformat (.Resources) that gets compiled into .NET assemblies by thecompiler. These compiled resources can be stored either alongside withcode in binary assemblies or on their own in resource satelliteassemblies whose sole purpose is to provide resources. Typically in.NET the Invariant culture resources are embedded into the baseassembly with any other cultures housed in satellite assemblies storedin culture specific sub-directories.

If you’re using Visual Studiothe resource compilation process is pretty much automatic – when youadd a .Resx file to a project VS.NET automatically compiles theresources and embeds them into assemblies and creates the satelliteassemblies along with the required directory structure for each of thesupported locales. ASP.NET 2.0 expands on this base process by furtherautomating the resource servicing model and automatically compilingResx resources that are found App_GlobalResources andApp_LocalResources and making them available to the application with aResource Provider that’s specific to ASP.NET. The resource providermakes resource access easier and more consistent from within ASP.NETapps.

The .NET framework itself uses .Resx resources to servelocalized content so it seems only natural that the tools theframework provides make resource creation tools available to servethis same model.

Resx works well enough, but it’s not very flexiblewhen it comes to actually editing resources. The tool support inVisual Studio is really quite inadequate to support localizationbecause VS doesn’t provide an easy way to cross reference resourcesacross multiple locales. And although ASP.NET’s design editor can helpwith generating resources initially for all controls on a page – viathe Generate Local Resources Tool – it only works with data in thedefault Invariant Culture Resx file.

Resx Resources are also static– they are after all compiled into an assembly. If you want to makechanges to resources you will need to recompile to see those changes.ASP.NET 2.0 introduces Global and Local Resources which can be storedon the server and can be updated dynamically – the ASP.NET compilercan actually compile them at runtime. However, if you use aprecompiled Web deployment model the resources still end up beingstatic and cannot be changed at runtime. So once you’re done withcompilation the resources are fixed.

Changing resources at runtimemay not seem like a big deal, but it can be quite handy during theresource localization process. Wouldn’t it be nice if you could editresources at runtime, make a change and then actually see that changein the UI immediately?

Using Database Resources

This brings me to storing resources in adatabase. Databases are by nature more dynamic and you can makechanges to data in a database without having to recompile anapplication. In addition, database data is more easily shared amongmultiple developers and localizers so it’s easier to make changes toresources in a team environment.

When you think about resourceediting it’s basically a data entry task – you need to look upindividual resource values, see all the different language variationsand then add and edit the values for each of the different locales.While all of this could be done with the XML in the Resx filesdirectly it’s actually much easier to build a front end to a databasethan XML files scattered all over the place. A database also gives youmuch more flexibility to display the resource data in different viewsand makes it easy to do things like batch updates and renames of keysand values.

The good news is that the resource schemes in .NET arenot fixed and you can extend them. .NET and ASP.NET 2.0 allow youcreate custom resource managers (core .NET runtime) and resourceproviders (ASP.NET 2.0) to serve resources from anywhere including outof a database.


As you perhaps know, default method (which is actually industry best practice) for Localizing .Net Applications is using resource files (.resx in this case). If you want to use database, you would have to write your own ResourceManager.

From this, the answer should be obvious: use standard and do not reinvent the wheel.

You might be wondering why Localization via resource files became industry-wide standard. Well, there are many reasons (too many to mention here), most of them regard to Localization process. The key one is, it is painfully hard to update (i.e. fix or install) translations for database driven Localization. Just think of what you need to install it - some SQL script. You know what will happen if you send out this for translation? Or even mistakenly update it? These kind of files are not very safe to work with (and they tend to be very large), so either you would need to create some kind of generator (with resource-like file as an input, which totally bits the purpose...) or you would need to be very careful (and pray that a translator won't break the file).

That is to say, database-driven Localization is sometimes the only sensible way of doing things - this is when you need to implement so-called dynamic Localization, that is allow users to translate things or add their contents in multiple languages.
For static Localization (typical scenario) use resource files.


Localizing user interface should not be stored in database, it is preferable to use the standard resx method because this will give you the flexibility to customize the user interface of front end for each client/deployment, without the need to change the back end or store much data about each client customization in database.

Regarding data (bi-lingual data or multi-lingual data) store them in database and use whatever technique suitable for the context (table per language, or duplicate columns for each language).