views:

47

answers:

2

I have a website that goes out to multiple clients. Sometimes a client will insist on minor changes. For reasons beyond my control, I have to comply no matter how minor the request. Usually this isn't a problem, I would just create a client specific version of the user control or page and overwrite the default one during build time or make a configuration setting to handle it.

Now that I am localizing the site, I'm curious about the best way to go about making minor wording changes.

Lets say I have a resource file called Resources.resx that has 300 resources in it. It has a resource called Continue. English value is "Continue", the French value is "Continuez".

Now one client, for whatever reason, wants it to say "Next" and "Après" and the others want to keep it the same. What is the best way to accomodate a request like this? (This is just a simple example).

The only two ways I can think of is to

  • Create another Resources.resx specific to the client, and replace the .dll during build time. Since I'd be completely replacing the dll, the new resource file would have to contain all 300 strings. The obvious problem being that I now have 2 resource files, each with 300 strings to maintain.
  • Create a custom user control/page and change it to use a custom resource file. e.g. SignIn.ascx would be replaced during the build and it would pull its resources from ClientName.resx instead of Resources.resx.

Are there any other things I could try? Is there any way to change it so that the application will always look in a ClientResources.resx file for the overridden values before actually look at the specified resource file?

+1  A: 

You could perhaps use the following template :

#if ClientName1 
Continue="Next";
#elif ClientName2
    Continue="Apres";
#else 
Continue="Continue" 
#endif

This allows you to specify all possible values in the same file (and the same variable in the same region), and you can easily define the symbol "ClientName1" from the commandline during the build.

apoorv020
A: 

I hate to say it, but the easiest thing might be to modify the application resource files with a custom action upon installation.

Using ResXResourceWriter / ResXResourceReader you and open the existing resource file(s) for the target culture and iterate through the tags you want to change. This obviously only makes sense if there are a few minor changes for a particular customer. This also assumes that the resource files are not embedded in the assembly.

Creating custom actions for Windows Installer is really easy as long as you are OK with running them after the installation completes.

An alternative would be to replace the default ComponentResourceManager with a version of your own that selectively changes the values of tags. This can also get ugly fast.

The last hack I can think of is to put all the default translation in the base resource file. The custom resource file only needs to change the tags it is interested in. Any tag left blank will get the original value. I'm not sure how realistic this is, as the default culture is likely English...

Edit: This may be a less hackish (still a hack!) solution. You can create another resource file within the same culture, like Belgian French. The Belgian French resource file will in essence inherit from the French resource file. This will allow you to change only a handful of text resources. Then, within your application, change the current culture to "fr-BE" instead of "fr". The customer will probably never know.

Scott P