views:

86

answers:

3

We're maintaining a web product that we've sold to several different customers. We support the site in native and english. As a part of the maintainence we've begun updating to .NET 3.5 and while during this we would like to have better support for differentiated layout/localization in the product.

We're trying not to have any customer logic containing inside the code. For example, we try to avoid code like this:

if (config.Customer = customer1)
    SetupPageForCustomer1();
else
    SetupPageForCustomer2();

Instead we try to put all customer differentiation in config files so we can have the much cleaner code:

SetupPageForCustomer(customer1)

void SetupPageForCustomer(Customer c)
{
   PageConfig pc = LoadPageConfig("config/" + c.Dir + "ThisPage.aspx.config");
   SetupPage(pc);
}

We've handled the layout differentiation by letting the pages that needs differentiation have a usercontrol for each customer that is loading dynamical on page_load. Localization is currently being handled with resource files which works great. Since we support two languages each page comes with two resource files. If we need to differentiate the text on these pages for customers, however, we will end up with (number of languages * number of customers) resource files which seemes to be a lot of maintainence work.

What are your views upon this issue? What is the best way to handle these kind of things?

+1  A: 

Perhaps you can split the localisation into two files. One file for the general content in the target language and then a file for the customer in that language. So assume you are going to a German translation you would have one file that was generic for all German customers and a file for each German customer. This is still a proliferation of files but would mean that each of the files wold be smaller and more specific.

PurplePilot
This doesn't change the fact that we will need a huge amount of files. Say we have 10 customers that means we would have 20 files per aspx page.
Qua
We eventually decided to go down this road. We have a base resource file that contains everything shared between several customers. Then in each customer file (which only exists if they have alternative resources) there is a possibility of overriding the base resources. We coded a custom resource handler to choose between the customer files.
Qua
A: 

This is a bit of a hack, but if you really need different text for different customers, it might be one of the more clean ways to do it:

From .NET 2.0 and on, you can create new cultures. (See How to: Create Custom Cultures.) I would suggest creating a new "culture" from your configuration file, inheriting from the culture representing the language in use. Once you have a new culture, you can create a resource file for just the strings specific to that customer, having it falling back on the defaults if no override is given.

Edit: Also, here's an article describing how to use culture for customer specific language use: .NET Internationalization: Using Custom Cultures

Freed
A: 

I cannot tell how your LoadPageConfig works.

Some ideas:

  • If you want to have as little files per customer, you could load your resource files dynamically (at run time) so you would not need to create extra cultures.
  • for real configuration differences, consider loading a single configuration file per customer with customer specific settings, as described in this article. The same approach can be used in ASP.NET.
Bernard Vander Beken