Localization

The ActiveX controls framework has some support for robust localization of your control—most notably, property pages and any other resources you want to localize.

The scheme is as follows: The resources for the default language (typically English) are in the main in-process server's resources. Then, for each additional language supported, a satellite DLL contains the resources for that language. The name for this satellite DLL is generated by taking the base name for the DLL from a string resource in the main in-process server file, and then adding on a three-letter language code as generated by the function GetLocaleInfo with the LCTYPE LOCALE_SABBREVLANGNAME.

The code first looks for the specific language that is set up in the global variable g_lcidLocale. This should be initialized by all servers. For ActiveX controls and property pages, get this from the host. For Automation servers, you can set this up some other way, often by using the system language. If the satellite DLL for the specific language is not found, the framework looks for the primary language ID with SUBLANG_DEFAULT. If that satellite is not found, a handle to the default resources is returned.

Fully localized type libraries are not supported; most hosts ignore these and just use the default.

Setting up for Localization

If you want to support satellite localization in your in-process server, then you need to set up some variables.

First, set to True the variable g_fSatelliteLocalization in your in-process server file. This instructs all further code paths to use satellite localization.

At some point, set up the g_lcidLocale variable, as described in the previous section.  For ActiveX controls, you can use GetAmbientProperty and ask for AMBIENT_DISPID_LOCALE. For property pages, a method on the IPropertyPageSite interface lets you obtain the locale identifier; for Automation objects, you are required to set this up yourself, typically by obtaining the system locale identifier.

Whenever you want to load a resource, make sure you use GetResourceHandle to get the instance handle for the localized resources. This generates the appropriate file name for the satellite DLL and attempts to load it. The satellite DLL contains all the localized resources you may want to use.