Don Box found Kraig Brockschmidt on the Web. I've used Kraig's book Inside OLE 2 for many years. I've used it even the time when the term ActiveX was preferred - it was still the best book (although outdated) in that area.
Kraig was into construction, singing, real estate, importing, photography, forest management, cooking, graphic design, mechanics, retail sales, childhood education, Yoga...... after his job at Microsoft.
Next week (16-18 Jul-2003) I'm teaching an Advanced C++ course. Although this course is not in our normal course program anymore, we had some customer requests - now the course nearly sold out. Also, in the last months I've helped one customer writing COM components using C++/ATL (this was a requirement by the client).
This will be a fun-week of RTTI, containers, iterators, algorithms, functors, adaptors...
The best option storing resources depends on the application type.
Windows Forms applications can use resource files or satellite assemblies. When to use what depends on the user/customer of the application. If it should be possible adding, changing resources for different languages just by using an editor (XML editor), resource files can be a good option. In most cases, satellite assemblies will be the better choice. With satellite assemblies resources are embedded in a binary format within a DLL. This makes the resources not so visible to the user, and faster access is possible. If the Windows application is not using a database directly, there is no need to think about putting the localization entries into the database.
With Web applications, using resource files is not a good option. The ResourceManager locks resource files, so it is not possible to update them with a running ResourceManager. So the two options left are satellite assemblies, and reading resources from the database. Because with a web application, usually a database is used, reading resources from the database is a perfect option. However, my sample of a resource reader to read resources from a database is just a simple implementation to show how to implement a custom resource reader. Adding caching functionality would be an useful task that can increase performance and scalability.
With web applications we should also differentiate between localized control values and content. If the content is read from the database, so should be the localized content. Localized control values can be read from satellite assemblies.
The Enterprise Localization Toolkit takes an interesting approach to localize web applications. It has some web applications and tools that make it easier to localize controls (not the content), and allows creating satellite assemblies.
To make this possible I've created a class EnterpriseCultureInfo that derives from CultureInfo. This way a EnterpriseCultureInfo object can be passed everywhere a CultureInfo is needed; e.g. setting the culture to the thread (CurrentUICulture property), or passing it as an argument of ToString() methods.
But there is one disadvantage of extending CultureInfo: CultureInfo requires passing a ISO-defined culture in the constructor. Because Klingon is not already defined with the .NET Framework, I've done a hack and set the culture of the base class to a valid value. I would prefer interfaces - the hack wouldn't be necessary if an interface ICultureInfo would be defined that is used instead of the CultureInfo class.
What makes the EnterpriseCulture different is allowing to set a extended culture. In my implementation, et-klingon and et-vulcano is allowed. In addition to that properties such as Name, DisplayName, EnglishName are overridden. Calendar information, time and number formatting could be defined, too.
In addition to the EnterpriseCulture class, a resource reader that supports Klingon is needed. My DBResourceReader class that I already mentioned in my previous post supports any language that is defined in the database.
In the database I've just added two Klingon words for the sample: "nuqneHdir" is Klingon's greeting. It is not really a "welcome", as such a meaning is not used with Klingon words. Instead this is the translation of "what do you want?" - Klingon's greeting. Goodbye is "Qapla'" in Klingon.
For my presentation at TechEd Barcelona I've created a custom ResourceReader to read localized values from a database instead of using resource files or satellite assemblies. This can be done very easily. All the code can be found on my web site:
1. Create a DBResourceReader class that implements the interface IResourceReader. The important method with this interface is GetEnumerator() that returns an IDictionaryEnumerator that can be used to enumerate the resources of one language. With this method I've read data from the database, stored it inside a Hashtable, and returned the enumerator of this hashtable.
2. Create a DBResourceSet class that derives from ResourceSet. All that's needed is passing a DBResourceReader to the constructor of the base class ResourceSet.
3. Create a DBResourceManager class that derives from ResourceManager. In this class I'm using the ResourceSets property of the base class to store DBResourceSets of multiple cultures. The method InternalGetResourceSet() must be overridden, so that DBResourceSets are returned. This method is called by the base class ResourceManager when resources are read. Instead of reading resources from the database every time, ResourceSets are put into a Hashtable.
With my TechEd presentation DEV-382, "Building International Applications with the Microsoft .NET Framework" I will not only show international applications, but also one example of a "universal" application.
I've extended the class CultureInfo to demonstrate how .NET applications can be translated to the Klingon language. Every developer should know the Klingon - from the Star Trek (Enterprise) series. A dictionary English - Klingon is available at Amazon.
Such an extension of the class CultureInfo is not only useful for applications outside earth, but can also be used to change the locality inside of regions. For example Styria, Vienna, Upper Austria (regions in Austria) do have some different words.
See you in room 9: Wednesday, 2-Jul, 18:15-19:30, DEV-382
More information about my other samples in this presentation is here.