views:

296

answers:

3

Hi,

I have many resource files, in many different languages.

Lets suppose for example we are supporting 3 languages (en, de, fr), and have this file:

common.resx common.de.resx common.fr.resx

I would like to detect occurrences when for instance a resource is requested in de, but is missing and so reverts to the default language. Is there any way of catching this? (so I can log it and later add the missing resource).

Thanks

A: 

There's nothing in the existing resource reading API that exposes fallbacks externally. However, System.Resources.ResourceManager is not sealed, so there's nothing stopping you from subclassing it to raise an event when fallback is required.

Nicole Calinoiu
+4  A: 

If you want to catch the differences use RESX Synchronizer. It is an open source app that can synchornize all differences from main resx to localized one (it adds and/or removes keys in the localized resource).

You can use it as follows to copy all changes from common.resx to common.de.resx:

resxsync /v common.resx common.de.resx

The /v option list all changes that is all keys that were added to or removed from the de resx.

Piotr Czapla
+1 Automating that seems straight forward and useful!
Greg
+1  A: 

Assuming that all resource file changes start in development and make their way to production, this seems like a job for some form of static analysis.

I use Zeta Resource Editor because it highlights areas that are missing translations and also placeholders (e.g. {0}).

Greg