Multi-Language Add-In for Visual Basic 6
The Multi-Language Add-In for Visual Basic 6 provides a general solution for creating and maintaining Visual-Basic projects with support for multiple languages.
The product is an Add-In for Visual Basic 6, which means that it is tightly integrated into development environment.
The basic steps involved in localizing an application are:
Identifying the strings to be translated
The Add-In scans your project, looking for strings defined in
|The properties of controls||The Add-In scans all Forms, UserControls and UserDocuments to find text properties which require translation. |
The relevant properties are defined in a Controls Database. This database already supports most commonly used controls and can easily be extended to support any other controls used in your project.
|The program source code||The Add-In shows all texts detected in the source code.|
In both cases, you can
- select the texts which you wish to translate
- hide texts which you do not wish to translate
Most programs contain a lot of text strings which do not require translation. In many cases, translation a string will actually cause a program error. Selecting the texts which require translation is a job which can only be performed by the programmer.
The Multi-Language Add-In makes it easy to start this job late in project development.
Specifying the languages to be supported
The Add-In shows you a list of all languages supported by Windows. Simply select a language from the list to add it to the project.
For each language, an additional column is added to the grids, showing the strings for this language.
There are two basic ways to enter translations. The one you choose probably depends on who is going to do the translation work.
|Enter translations directly||The simplest way to enter a translation is to type it into the grid.|
When you click in a cell, the Add-In will immediately show the location of the text in the source code, or in a designer window. This makes it easy to identify where and how the text is used.
The Add-In contains a database of common translations, so terms such as OK and Cancel will usually be translated automatically.
The Add-In also contains a translation memory feature, which shows you translations of other texts containing the same words.
This is the best approach, if the programmer is able to translate the texts herself or himself.
|Enter translations with Microsoft Excel||In most cases, you will need to send the texts to a translator. |
In this case, you can
- export the texts to an Excel file
- have the texts translated in the Excel file
- import the translated texts back into the project from the Excel file
Using the translations
There are two fundamental ways to use the translations. You can either:
- create multiple single-language versions of your program or
- create a single multi-language version of your program.
Single language versions
Using the Multi-Language Add-In, it is simple to generate a single language version of your project. You select the language and the Add-In will:
- create a complete copy of the project in a new directory
- exchange the original texts for the translated texts in the selected language
- compile the new project
- reload the original project
Creating a multi-language version
There are two aspects to creating a multi-language version of your project:
- storing the translated texts as resource strings
- adding runtime support for switching the language
To switch the language, the Add-In generates a new function in each Form, UserControl or UserDocument to load the localized texts into the properties of controls in the user interface. A call to this function is added to the Form_Load, UserControl_Initialize or UserDocument_Initialize function.
Language selection and language switching
The Add-In can add a form to your project, which can be used to select the language. This form can be shown:
- when the program is started or
- at any time when the program is running
The Add-In can add code to your project, to show this form before any other forms are loaded. In this case, the language is selected before any other initialisation code runs.
If you want to change the language at a later stage, then an event mechanism can be used to generate events in all active components, indicating that the language has been changed. The events are generated via a singleton object in the module MLRuntime.dll, which has the great advantage that events can be generated across multiple, separately compiled modules. The Add-In can automatically add the necessary event handlers to support this mechanism. The module MLRuntime.dll can be freely distributed with your application.