After you have installed the Add-In, there will be a new menu item in the Tools menu in Visual Studio.
This menu item activates the Add-In and shows it in a tool-window. You can dock this window at the side of the main Visual Studio window, or drag it into a tab group, like other tool windows in Visual Studio. It's probably best to place it at the bottom, in a wide format.
A Visual Studio solution may contain multiple projects. However, the Multi-Language Add-In always works with a single project. To get started, you must first select the project. There are two ways to do this.
| from a dialog | When you select the Add-In from the tools menu, it will probably show a list of the projects in a dialog. Simply select the project and click on OK.
This dialog can be disabled, so if somebody else has already worked with the Add-In, it might not appear. |
| from a drop down list | At the top of the Add-In's main window, just below the toolbar, there is a drop down project list
You can select a different project at any time from this list. |
When you select a project for the first time, you must specify what the original language of the project is. The Add-In will show a list of the languages supported by Windows.
Select the original language and click on OK.
(The buttons below the list change the way the list is displayed. In particular, the button English simply shows the language names in English. It does not select English in the list).
This dialog will probably be followed by second dialog, with options for scanning the project. Just click on OK to accept the default options.
The Add-In will now add two new files to your project.
| <project name>_ml.mlb | This is the project database used by the Add-In. It is added to the project with BuildAction=None. |
| mlstring.vb or mlstring.cs or mlstring.h + .cpp | This module contains support functions, in particular the function ml_string(), which is used to load localized strings. |
The Add-In will now scan the project. This is performed in two phases:
In the first phase, the controls in each Form and each ))UserControl(( are scanned for properties with the localizable attribute. In the second phase, the source code of the project is scanned for texts which may require translation.
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.
To add a new language to the project, click on the
symbol on the Add-In's toolbar
This brings up a dialog very similar to one where we selected the original language of the project.
Select a new language and click on OK to add this language to the project.
Some languages, such as German or French, are considered to be neutral languages. The regional variations, such as German(Germany), German(Austria), French(France) or French(Canada) are referred to as specific languages. You should always add the neutral language before adding a related specific language. If you do choose to add a specific language, the Add-In will give you the option of adding both neutral and specific languages or only the neutral language.
After adding the second language, the Add-In will
Now we will take a closer look at the two grids.
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.
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 or ))UserControl(( in a flat list. To select this mode, click on the
button on the toolbar and then select Flat list from the menu, as shown below:
The controls grid will then look something like the following screenshot.
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.
If a text is shown in light grey, then it is the text which would be retrieved at runtime via the resource fallback mechanism. In general, if a text is not defined for a specific language (e.g. Spanish(Mexico)) then the text for the neutral language (e.g. Spanish) would be used. If this has not been defined, then the original text in the project would be used.
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.
In fact, we never really want to see these properties again, so we can go one step further and hide them completely. To do this, we first click on the sun symbol
at the left hand margin. The sun symbol is replaced by a moon symbol
.
To actually hide the lines, click on the mask symbol on the toolbar
. If you want the hidden properties to be shown again, click on the
button on the toolbar and select ''Show hidden properties" from the menu.
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 localizable properties containing empty strings, then you can modify this option in the settings dialog. To show this dialog click on the settings button
on the toolbar. Details of this and other options are described in the online help file.
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.
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
on the toolbar.
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.
As you can see, this function has two parameters:
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.
The exact format of the function ml_string depends on the computer language used in the project.
| C# | OpenFile.Title = ml.ml_string(27, "Open") ; |
| VB.NET | OpenFile.Title = ml_string(27,"Open") |
| C++ | OpenFile->Title = ML_STRING(28, "Open") ; |
The function ml_string is implemented in the module mlstring which was added to the project from a template file (usually in the directory C:\Program Files\MultiLang2005\Templates).
Once a string has been selected for translation, you can enter a translation simply by typing a new text into the grid.
As with the controls grid, we also have the option of hiding texts which do not require translation. For example, none of the texts in the module AssemblyInfo.cs need to be translated.
As before, we hide a string by clicking on the sun symbol
at the left hand margin, which is then replaced by a moon symbol
. At the same time, the comment //MLHIDE ('MLHIDE in VB.NET) is added to the end of the source code line, to mark it as hidden.
To actually hide the lines, click on the mask symbol on the toolbar
. This works a little differently to controls grid. The hidden items are collapsed behind a new node hidden and you can view them at any time simply be expanding this node.
It is good practice to either select or hide every string in the project. If new strings are added to the source code, 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.