History: MultiLangVsNetQuickTourWindowsStore

Preview of version: 24

Multi-Language Add-In for Visual Studio

Quick Tour (Windows Store Apps)

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. The Multi-Language Add-In usually 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

When you select a Windows Store project, the Add-In will automatically detect:

  • Any languages which are already defined in the project.

    This is determined from the subdirectories in the directory Strings, containing a file called Resources.resw.
Image
  • The default language of the project.

    This is defined in the input mask for the Package.appxmanifest
    (although it is actually stored in the project file).

    If the default language of the project has not been defined, then the Add-In will show a dialog with a list of languages. You must select the language used for the original texts in the project.
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 two new files to your project.
<project name>_ml.xmlThis is the project database used by the Add-In. It is added to the project with BuildAction=None.
mlstring.vb or
mlstring.cs
This module contains support functions, in particular the function ml.GetString(), which is used to load localized strings.

Scanning the project

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

Resource files String resources defined for the default language in a resource file with the .resw extension are read and displayed in the Resources tab.
ControlsThe user interface definition in the XAML files is read. Texts which can be translated are displayed in the Controls tab.
Source codeThe project source code is scanned for texts which may require translation. The texts are displayed ih the Source code tab.
Image
The results of the scan are displayed in three separate grids in the Add-In's window.

You can switch between these grids using the tabs at the bottom of the window.

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
Select a new language from the list.

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.

If the Microsoft Translator supports both the default language and the selected language then the option Get translations from Microsoft Translator is enabled. Similarly for the Google Translator.

Select one of these options if you want the texts to be translated automatically using an online service.

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 usually start with the neutral language.

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
  • if you selected the Microsoft or Google Translator option, then it will translate all other texts using the online service

It will only translate texts which have been selected for translation. If you are following this as a tutorial, it will not actually translate anything, because we have not yet selected any texts.


Now we will take a closer look at the three 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 text attributes are shown in a hierarchical manner, showing the structure of the XAML file. As an alternative, you can view the text attributes for each XAML file 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

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

Image

Using the flat list is recommended. In fact, the structured view may be removed in a future version.

If an element in the XAML structure does not have a name, then it is assigned one by the Add-In. As you can see, these names have the form ML_0000 with 0000 is a numeric value.

To the left of each name of each text attribute there is a check box which indicates whether the attribute has been selected for translation. Initially, none of the attributes are selected. To select an attribute, simply click on the check box. Alternatively, you can select the line and hit the space bar.

Image

As you can see, the grid has a column for each language in the project. Once a property has been selected, you can enter a translation simply by clicking on the cell in the appropriate column and entering the translation. 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 text for the default language would be used.

When you select a text attribute, the XAML code may be modified, so that the attribute is initialised from a resource file. The exact modification depends on several factors, as described below:

Text attribute of a XAML control
The attribute x:Uid is added. The Uid is always generated in the form ML_0000, because it must be unique in the complete project.
A resource string is defined with the name <Uid>.<Attribute name>

Before
<Button Content="OK" x:Name="OKButton" Click="OKButton_Click" />

After
<Button Content="OK" x:Name="OKButton" Click="OKButton_Click" x:Uid="ML_0009" />

A resource string with the name ML_0009.Content is defined with the text "OK".
A simple text in a TextBlock control
A single text can be handled as a Text attribute, and localized with a resource with the name <Uid>.Text.

Before
<TextBlock>One</TextBlock>

After
<TextBlock x:Uid="ML_0011">One</TextBlock>>

A resource string with the name ML_0011.Content is defined with the text "One".
One of multiple texts in a TextBlock control
If there is more than one text in a TextBlock, the text is replaces with s Run tag, which can be localized with the Text attribute.

Before
Here, the content of the TextBlock is broken by a LineBreak tag.

<TextBlock>One<LineBreak/>Two</TextBlock>

After
<TextBlock><Run x:Uid="ML_0014">One</Run><LineBreak />Two</TextBlock>

The text before the LineBreak is converted to a Run tag and assigned the Uid ML_0014.
A resource string with the name ML_014.Text is defined with the text "One".




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

History

Information Version
Thu 13 of May, 2021 21:28 GMT Phil 47
Sat 04 of Jul, 2020 11:57 GMT admin 46
Sun 28 of Jun, 2020 18:06 GMT Phil 45
Sun 04 of Dec, 2016 17:23 GMT Phil 44
Sat 24 of Jan, 2015 17:49 GMT Phil 43
Fri 23 of Jan, 2015 22:10 GMT Phil 42
Fri 23 of Jan, 2015 22:07 GMT Phil 41
Fri 23 of Jan, 2015 22:05 GMT Phil 40
Fri 23 of Jan, 2015 21:39 GMT Phil 39
Fri 23 of Jan, 2015 21:29 GMT Phil 38
Fri 23 of Jan, 2015 21:02 GMT Phil 37
Thu 22 of Jan, 2015 22:36 GMT Phil 36
Wed 21 of Jan, 2015 22:28 GMT Phil 35
Wed 21 of Jan, 2015 21:49 GMT Phil 34
Wed 21 of Jan, 2015 21:39 GMT Phil 33
Tue 20 of Jan, 2015 22:20 GMT Phil 32
Tue 20 of Jan, 2015 22:17 GMT Phil 31
Tue 20 of Jan, 2015 21:59 GMT Phil 30
Tue 20 of Jan, 2015 21:36 GMT Phil 29
Mon 19 of Jan, 2015 22:25 GMT Phil 28
Mon 19 of Jan, 2015 22:23 GMT Phil 27
Mon 19 of Jan, 2015 22:21 GMT Phil 26
Mon 19 of Jan, 2015 22:07 GMT Phil 25
Sun 18 of Jan, 2015 22:16 GMT Phil 24
Sun 18 of Jan, 2015 22:08 GMT Phil 23
  • «
  • 1 (current)
  • 2