Share via


Visual Basic Concepts

Localizing ActiveX Components

You can localize components created using Visual Basic by first collecting all the text strings used in your component into a source file for the Windows Resource Compiler (.rc file). You can then create localized versions of this source file by translating the strings to each of your target locales.

Before you compile each localized version of your component, use the Resource Compiler to create a Windows resource (.res file) from the appropriate source file, and include the resource file in your project.

Components without a visible interface are extremely easy to localize in this fashion, because you only have to localize error messages. The code fragments in "Generating and Handling Errors" demonstrate this technique.

For components that display forms, the process is more complicated. You need to place the captions of forms and controls into the resource file, and retrieve them in the Form_Load event procedure for each form.

Satellite DLLs

In areas where multiple languages are in use, using resource files can be a problem. Not only do you have to compile separate versions of your component for each language, but they all share the same Project Name, and thus only one language can be installed on a user’s computer at any given time.

Localizing Controls" in "Building ActiveX Controls," describes a technique for using a satellite DLL to provide the translated strings for each language. Satellite DLLs accompany your component, and can be swapped in and out without recompiling the component.

If you use a LocaleID-based naming convention, multiple satellite DLLs can coexist on one computer, allowing the user to switch from one language to another by changing the system LocaleID.

Limitations

Unfortunately, code components can only make limited use of this feature. Unlike control components, they don’t receive a LocaleID from the client application. The best a code component can do is to use API calls to obtain the system LocaleID.

Out-of-process code components can never do any better than this, because they have to serve multiple clients. With in-process components, however, you can offer developers a better option by providing an object with a LocaleID property that can be set by client applications. When the property is set, your component can load text strings from the appropriate satellite DLL.

For More Information   For information on writing code for applications that will be distributed world-wide, see "International Issues," in the Visual Basic Programmer’s Guide. To learn about the functions for retrieving text strings and other resources, see the LoadResString function in the Language Reference.