Loading...
 

History: MultilangVsNetQuickTourMFC

Preview of version: 5

Multi-Language Add-In for Visual Studio

Quick Tour (Unmanaged C++ and MFC)

Support for unmanaged C++ and MFC projects is only available in the Add-In version for Visual Studio 2005/2008.

Activating the Multi-Language Add-In

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. 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.
Image

Selecting a project

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 dialogWhen 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.
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

The Add-In will automatically detect the languages defined in the resource script (.rc) file in your project. For a non-localized project, the resources will usually be defined for a single language. The Add-In assumes that the first language which it detects is the original language of the project.


In the unlikely case, that no languages are defined in the .rc file, 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).
Image
Image

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 three new files to your project.

<project name>_ml.xmlThis is the project database used by the Add-In.
mlstring.h + .cppThis 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 controls
  • scanning source code

In the first phase, the Add-In scans the resource script (.rc) file for dialog and menu resources and extracts the texts from the resource definitions. 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.
Image
In fact, the controls scan is performed in four steps:

Read resource symbolsIn this step, the Add-In reads the resource symbols defined in the file resource.h (in your project) and afxres.h (from Microsoft).
Import resource stringsIn this step, the Add-In reads all resource strings in the .rc file and imports them into the Add-In's project database.
The languages defined in the .rc file are also imported automatically.
Remove IDC_STATICIn this step, the Add-In searchs the .rc file for use of the resource symbol IDC_STATIC. This symbol is commonly used for static controls, in particular labels, which never need to be fererenced in the source code.

For the Add-In, it is important to be able to identify each control with a unique ID (at least within a single dialog). For this reason, it replaces each use of IDC_STATIC with a unique symbol of the form IDC_STATICnnnn, where nnnn is the numerical value assigned to the control. The Add-In increments the symbol _APS_NEXT_CONTROL_VALUE in resource.h each time it generates a new symbol
Scan dialogs and menusFinally, the Add-In actually scans the dialog and menu resources and extract the texts.

Adding a second language

To add a new language to the project, click on the Image 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.
Image
Image
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.

Note
I am not sure how well neutral languages are supported in unmanaged C++ projects. Let me know if you have problems with this.

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
As you can see, the grid shows the texts from dialog resources and menu resources.

By default, menu resources are shown in a hierarchical manner, reflecting the structure of the menu.

As an alternative, you can view the menu items in a flat list. To select this mode, click on the Image button on the toolbar and then select Flat list from the menu, as shown below:
Image
Image
The menu will then be shown as in the second screenshot.

This option has no effect on the display of dialog resources.
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.

If a text is shown in light grey, then the text has been generated by the resource fallback mechanism. If a text is not defined for a specific language (e.g. Spanish(Mexico)) then the text for the neutral language (e.g. Spanish) will be used. If this has not been defined, then the original text in the project would be used.

Note
For unmanaged C++ projects, the Add-In handles resource fallback when it exports the texts to the .rc file. The Win32 resource functions do not resource fallback. (In contrast, resource fallback is built in to the .NET common language runtime (CLR).

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.

The following screenshot is based on the MFC sample program CmnCtrl2. You can see that some of the controls have a text property which will not require translation.
Image
Since we do not want to translate these texts, we can deselect them by clicking on the check boxes.
Image
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 Image at the left hand margin. The sun symbol is replaced by a moon symbol Image .
Image
To actually hide the lines, click on the mask symbol on the toolbar Image . If you want the hidden properties to be shown again, click on the Image 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 Image on the toolbar. Details of this and other options are described in the online help file.

Actually, it appears that this is not true for MFC projects in version 4.60.0008. This is a bug which will be fixed.

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.




History

Information Version
Sat 17 of Jul, 2010 14:03 GMT Phil 14
Sat 17 of Jul, 2010 13:47 GMT Phil 13
Sun 10 of Jan, 2010 13:14 GMT Phil 12
Sat 09 of Jan, 2010 19:20 GMT Phil 11
Sat 09 of Jan, 2010 15:23 GMT Phil 10
Sat 17 of Jan, 2009 21:30 GMT Phil 9
Sat 17 of Jan, 2009 21:09 GMT Phil 8
Sat 17 of Jan, 2009 18:39 GMT Phil 7
Sat 17 of Jan, 2009 18:13 GMT Phil 6
Sat 17 of Jan, 2009 16:56 GMT Phil 5
Sat 17 of Jan, 2009 16:11 GMT Phil 4
Sat 17 of Jan, 2009 16:02 GMT Phil 3
Sat 17 of Jan, 2009 15:07 GMT Phil 2
Sat 17 of Jan, 2009 14:37 GMT Phil 1
  • 1
  • 2 (current)
  • »