views:

1912

answers:

3

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.

+3  A: 

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.

Ian Suttle
thanks ian. thats kind of the direction i was leaning towards. i just havent had to localize anything before. in fact i dont need to localize anything YET but i want to be prepared. i just found myself skipping over most of the content as not relevant and it left me curious as to what i should do
Simon_Weaver
We're going through the pains of localizing sites right now. For us it's a group of apps which work together and have been around for a few years. That's no small task :). Definitely at least consider this before committing to how you're going about things. I hope that helps and saves you work:)
Ian Suttle
i'm wondering too if there is any layer of abstraction with resources, for instance so I could add a * at the beginning of every string and then know what I have and haven't localized. Obviously with an HtmlHelper I can do that myself quite easily - but maybe theres some other things to learn too
Simon_Weaver
One recommendation I thought was quite useful was to use FXCop on your code to point out things that won't localize properly.I've not seen a standard such as prefixing text with a * but I definitely see the benefit there. Perhaps swap out a resx for another w/ obviously wrong data like "mmmmm"
Ian Suttle
+3  A: 

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).

Franci Penov
+2  A: 

If you are going to use Resx and not use Server Controls as you are in MVC, why not extend the MVC Helper methods so you can create localised labels and text? Then simply call the text from resource in the helper method.

e.g. '<%=Html.CultureLabel("ResouceId") %>'

or '<%=Html.CultureButton("Name","ResouceId", HtmlButtonType.Button) %>'

Just a thought.

Also managing globalisation of a site is MUCH easier with resx for the text.

Richard
+1 for extending a helper method - very nice.
Ian Suttle