Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What advantages are the of using .resx localization for an ASP.NET MVC app?

There are a number of questions on this site related to how to access RESX files in an ASP.NET MVC application, and best practices of using them.

However after reading (for the first time I might add) the MSDN article on resources I'm left wondering if there are even any advantages of using RESX files since I'm not going to be using server controls. Theres all this talk of 'implicit' and 'explicit' localization but I'm not going to benefit from that with MVC.

Ultimately my application will need string resources for buttons and menu items and also much longer HTML items for longer miscellaneous content. I would like to use a CMS for the longer items becuase I'm pretty sure I don't want to go sticking them into an RESX file.

Are there any compelling reasons to use or not to use ASP.NET resources in a new application. I'm going to assume that any future MVC enhancements or RESX enhancements will work in harmony together, but for now I'm just getting a glorified IDictionary as far as I can see.

Should I proceed with RESX or look elsewhere? Should I even be considering a CMS for the kinds of resources that RESX is designed for?

Any lessons learned would be appreciated.

like image 534
Simon_Weaver Avatar asked Mar 04 '09 05:03

Simon_Weaver


People also ask

What is MVC localization?

Localization is the process of adapting software to meet the requirements of local markets and different languages. You can change the messages that are displayed in the Telerik UI for ASP.NET MVC helpers by including an additional script file in the document.

Which ASP.NET folder contains * .resx files that are bound to a specific page?

Global Resource Files resx file that is in the App_GlobalResources folder has global scope. Additionally, ASP.NET generates a strongly typed object that gives you a simple way to programmatically access global resources.

What is resources Resx?

The . resx resource file format consists of XML entries that specify objects and strings inside XML tags. One advantage of a . resx file is that when opened with a text editor (such as Notepad) it can be written to, parsed, and manipulated.


2 Answers

There are couple of advantages to the RESX infrastructure:

  • you don't have to load the proper per-language resources. Once the locale of the thread is established, the CLr takes care of finding the appropriate assembly and loading the resources.
  • it is easy to hand off the locale-specific resources for localizations to third-parties.
  • there is a default fallback mechanism for non-localized resources.

There is also one particular disadvantage to the RESX approach:

  • it is hard to support translation model where the users translate your resources for you.

I'd like to elaborate a bit about that last point. Take for example the Facebook translation model. Facebook has fairly simple way for people to provide and vote on translations of various resources. If these are stored in a database, it would be possible to use them after the proper editorial process without rebuilding and redeploying the application. With the RESX model, the resources assemblies will have to be rebuild and redeployed, which could have high enough cost depending on the deployment process.

Thus, before deciding what localization process to use, I would look at the decision of who is going to do the localization and what the deployment process for the localizaed resources would be after the main application is already deployed.

EDIT: I forgot to mention that these considerations are orthogonal to the ASP.NET framework choice (MVC or WebForms).

like image 170
Franci Penov Avatar answered Oct 15 '22 04:10

Franci Penov


I'd say "yes", resx files are still a good option for new applications. I don't think ASP.NET MVC in particular changes anything about storing your strings.

What's great about using resources is

  • they're pretty easy to manage
  • localizing your site is a much easier task than without resources (and I stress much easier)
  • you can replace the resource store at any time because resources use the provider model. You can switch out resx files for db entries without changing the implementation of your site.

I recommend resource files for the "site strings" which are different than the large blocks of data you might edit on a frequent basis. So for a full recommendation, I'd say use resource files (resx to start) for buttons, labels, etc, and a CMS for the meaty content.

like image 34
Ian Suttle Avatar answered Oct 15 '22 03:10

Ian Suttle