History: MultilangVB6QuickTour

Preview of version: 9

Multi-Language Add-In for Visual Studio

Plugin execution pending approval

This plugin was recently added or modified. Until an editor of the site validates the parameters, execution will not be possible.

Plugin execution pending approval

This plugin was recently added or modified. Until an editor of the site validates the parameters, execution will not be possible.

After you have installed the Add-In, there will be a new menu item in the Tools menu in Visual Studio.

Image
This menu item activates the Add-In and shows it in a tool-window. Like other tool windows in Visual Basic, you can dock this window at any side of the main Visual Basic window. It's probably best to place it at the bottom, in a wide format.
Image
You may close the window at any time and reopen it using the Add-Ins menu.

Selecting a project

In Visual Basic, you may work with a project group containing multiple projects. However, the Multi-Language Add-In always works with a single project. To get started, you must first select a project. There are two ways to do this.

from a dialogWhen you select the Add-In from the Add-Ins menu, it will probably show a list of the projects in a dialog.
Simply select the project and click on OK.
Image
This dialog can be disabled, so if somebody else has already worked with the Add-In, it might not appear.
from a drop down listAt the top of the Add-In's main window, just below the toolbar, there is a drop down project list
Image
You can select a different project at any time from this list.

Initialising the project for localization

When you select a project for the first time, you must specify what the original language of the project is. You can select the language from a drop down list containing all of the languages supported by Windows.

It is also possible to specify a non standard language, but this is not recommended.
Image
The Add-In will now add two new files to your project.
<project name>_ml.mdbThis is the project database used by the Add-In. It is added to the project as a related document.
mlstring.vbThis module contains support functions, in particular the function ml_string(), which is used to load localized strings.

Scanning the project

The Add-In will now scan the project. This is performed in two phases:

  • scanning source code
  • scanning controls

In the first phase, the source code of the project is scanned for texts which may require translation. In the second phase, the controls in each Form, UserControl and UserDocument are scanned for properties containing strings.

The results of the scan are displayed in two separate grids in the Add-In's window. You can switch between these grids using the tabs at the bottom of the window.
Image

The controls database

At this point, you may see one or more error messages in the Errors tab.
Image
For example, the screenshot shows the error message TDBDate6Ctl.TDBDate not found in the Controls-Database. This error is easy to fix, but first we must take a look at the Controls Database.

You may already have wondered, how the Multi-Language Add-In knows which properties require translation and whether it is restricted to a small number of common controls. The Add-In uses a database to store details of which properties may require translation. The initial version of this database contains the standard VB controls and some of the most commonly used controls. It is easy to add additional controls to the database yourself.

The error message shown above contains a shortcut to add the control to the database. Simply click on the yellow database symbol Image to open the database editor. The first time you click on this symbol, a form will appear while the Add-In build a list of available controls. After this, the controls database editor will be opened for the control indicated in the error message.
Image
The list at the top left hand side shows the string properties of the control, plus additional objects which may be expanded to show additional properties. In most cases, you simply have to select the properties which require translation and close the dialog with the close button.

The list at the bottom left hand side shows the properties which have been selected. You will usually need some knowledge of the control to determine which properties require translation. (In the specific case shown TDBDate6Ctl.TDBDate, I have no idea which properties really require translation.)

After updating the controls database, you must rescan your project, before the changes take effect.

You can view the complete contents of the controls database, by clicking on the yellow database symbol Image on the toolbar.

The database format is very flexible and can handle all of the following cases:

Simple text propertiesThe most basic type of property
String arrays
Simple objects
Collections
Object arrays



Adding a second language

To add a new language to the project, click on the Image symbol on the Add-In's toolbar
Image
Image
This brings up a dialog with which you can add a new language to the project.

You can select a language from a drop down list showing all of the languages supported by Windows. Then simply click on OK to add the language to your project.

If you wish, you can initialise the texts in the new language based on the texts for another language, but this is not recommended.
After adding the second language, the Add-In will
  • add a new column to the grids for the new language
  • search for translations of common texts such as OK and Cancel in the Global Translations Database


Now we will take a closer look at the two grids.

The controls grid

To see the controls grid, make sure that the controls tab at the bottom of the window is selected. The grid should look something like the following screenshot.
Image

By default, the properties are shown in a hierarchical manner, showing the association of properties to controls. As an alternative, you can view the properties on each Form, UserControl or UserDocument in a flat list. To select this mode, click on the Image button on the toolbar and then select Flat list from the menu.
Image

The controls grid will then look something like the following screenshot.

Image
To enter a translation, simply click in cell and type in the new text. If you are able to translate the text yourself, this is the easiest way enter translations.

The check boxes to the left of the property name indicates that the text has been selected for translation. By default, all properties which contain a non empty string are selected. In the screenshot above, you can see two menu separators with the text "-". It makes no sense to translate these, so we can remove deselect them by clicking on the check boxes.
Image

By default, properties containing empty strings are not shown in the grid. It very rarely makes sense to translate empty strings, so this if sensible setting. If you do want to see properties containing empty strings, then you can modify this option in the settings dialog. To show this dialog click on the settings button Image on the toolbar. Details of this and other options are described in the online help file.

The source code grid

To see the source code grid, make sure that the source code tab at the bottom of the window is selected. The grid should look something like the following screenshot.
Image
As in the controls grid, you can select a string for translation by clicking in the checkbox to the left of the line number. In contrast to the controls grid however, none of the texts are selected automatically.

When you click on a line in the source code grid, the corresponding line in the source code will be shown in the source editor.

Alternativly, if you select a line in the source editor, which contains a string, you can locate this line in the source code grid by clicking on the goto line button Image on the toolbar.
Image
Image
Another way to locate a line in the source code grid is to select Show in Multi-Language from the context menu in the source code editor.

When you select a string for translation by clicking on the checkbox, the Add-In will assign a string ID number to the text and insert a call to the function ml_string() into the source code.
Image
As you can see, this function has two parameters:

  • the String ID number and
  • the original text

In fact only the string ID will actually be used, so you could consider the original text as a comment. Leaving the original text in the source code serves to make the code more readable. Once a string has been selected for translation, you can enter a translation simply by typing a new text into the grid.

The function ml_string is implemented in the module MlStringModule.bas which was added to the project from a template file (usually in the directory C:\Program Files\MultiLang\Templates).

If you do not select a string for translation, you have the option of hiding the string instead. To hide a strign, we first click on the sun symbol Image at the left hand margin. The sun symbol is replaced by a moon symbol Image . At the same time, the comment 'MLHIDE is added to the end of the source code line, to mark it as hidden.
Image
To actually hide the lines, click on the mask symbol on the toolbar Image . The hidden items are collapsed behind a new node hidden and you can view them at any time simply be expanding this node.
Image
It is good practice to either select or hide every string in the project. If new strings are added to the source code at a later stage, it is then much easier to find the new strings in the grid. Of course, you can also add the MLHIDE comment to lines in the source code editor. When the Add-In scans the project, it will automatically hide these strings.

History

Information Version
Sun 04 of Dec, 2016 17:44 GMT Phil 19
Wed 24 of Dec, 2008 23:16 GMT Phil 18
Thu 24 of Jan, 2008 21:44 GMT admin 17
Mon 21 of Jan, 2008 22:29 GMT admin 16
Sat 12 of Jan, 2008 17:58 GMT admin 15
Sat 12 of Jan, 2008 17:33 GMT admin 14
Sat 12 of Jan, 2008 15:35 GMT admin 13
Sat 12 of Jan, 2008 14:41 GMT admin 12
Sat 12 of Jan, 2008 12:31 GMT admin 11
Sat 12 of Jan, 2008 12:23 GMT admin 10
Sat 12 of Jan, 2008 11:09 GMT admin 9
Fri 11 of Jan, 2008 21:36 GMT admin 8
Fri 11 of Jan, 2008 21:33 GMT admin 7
Thu 10 of Jan, 2008 22:47 GMT admin 6
Thu 10 of Jan, 2008 21:17 GMT admin 5
Thu 10 of Jan, 2008 21:11 GMT admin 4
Thu 10 of Jan, 2008 21:04 GMT admin 3
Thu 10 of Jan, 2008 20:47 GMT admin 2
Thu 10 of Jan, 2008 20:42 GMT admin 1