Share via


Supporting Multiple National Languages

Applications sometimes need to expose objects with names that differ across localized versions of the product. The names pose a problem for programming languages that need to access these objects, because late binding will be sensitive to the locale of the application. The IDispatch interface provides a range of solutions that vary in cost of implementation and quality of language support. All methods of the IDispatch interface that are potentially sensitive to language are passed a LCID, which identifies the local language context.

The following are some of the approaches a class implementation can take:

  • Accept any LCID and use the same member names in all locales. This is acceptable if the exposed interface will typically be accessed only by very advanced users. For example, the member names for OLE interfaces will never be localized.

  • Accept all LCIDs supported by all versions of the product. In this case, the implementation of GetIDsOfNames would need to interpret the passed array of names based on the given LCID. This is the most acceptable solution because it allows users to write code in their natural language and run the code on any localized version of the application.

  • Return an error (DISP_E_UNKNOWNLCID) from GetIDsOfNames if the caller's LCID does not match the localized version of the class. This prevents users from being able to write late-bound code that runs on machines with different localized implementations of the class.

  • Recognize the particular version's localized names, as well as one language that is recognized in all versions. For example, a French version might accept French and English names, where English is the language supported in all versions. Users who want to write code that runs in all countries/regions would have to use English names.

To provide general language support, the application should check the LCID before interpreting member names. Because Invoke is passed a LCID, methods can properly interpret parameters whose meaning varies by locale. The following sections provide examples and guidelines for creating multilingual applications.

In this section

Topic Description
Implementing IDispatch for Multilingual Applications
When creating applications that will support multiple languages, you need to create separate type libraries for each supported language, as well as for versions of the IDispatch member functions that include dependencies for each language.
Implementing the IDispatch Member Functions
The IDispatch member functions must be implemented in such a way as to take into account any language-specific features.
Creating Separate Type Libraries
For each supported language, write and register a separate type library.
Defining the Locale IDs
Demonstrates how to use locale IDs.
Loading Type Information
Demonstrates how to load locale-specific type library information.
Interpreting Arguments and Strings Based on the Locale ID
Some methods or properties need to interpret arguments based on the LCID.