Click or drag to resize

Adding support for several languages

Introduction

This chapter provides the information needed to localize a customized application. The FlexPendant has built-in support for localization, and the mechanisms used by the standard FlexPendant applications can also be used by FlexPendant SDK applications.

This enables customized applications to be presented in the active language of the FlexPendant, that is, the language selected in the standard view Control Panel-Language.

For this to work the texts displayed in the customized application must be translated and the application localized as described in this chapter.

Get started

Develop the application using English as the default language. The recommendation is to design, implement and test the application before adding support for other languages. To localize a FlexPendant application carefully complete each procedure of this chapter.

Note Note

A method is needed to handle localization when new application functionality is added.

1 Create project for text resources

This procedure sets up a separate project for the user interface texts.

Step

Action

1

Create a new project in the solution. Choose a Smart Device-Windows CE 5.0- Empty Projectand name the project <YourAppName>Texts.

Tip Tip
Both projects should belong to the same solution. The application will now compile to three assemblies:

<YourAppName>.dll, <YourAppName>.gtpu.dll and <YourAppName>Texts.dll

2

In the Texts project add a reference to System (.Net).

3

Set the Output type to Class Library (this is done in the Project Properties).

4

The namespace used for the Texts project must be the same as used for the main project. As the namespace is not visible in the resource file you must change it in the Project Properties like this:

project properties

5

Add a Resources file to the project by right clicking the project in Solution Explorer and selecting Add New Item. Set the name of the file to “Strings.resx". This file will contain the texts of the default language (normally English).

6

Open the resource file and add name and value for the texts of the default language. Use capital letters in the name column.

data for data

7

In the Texts project create a folder with the culture short form as name, for example de for German and for sv Swedish.

texts
Note Note
Russian (ru) has been added in RobotWare/FlexPendant SDK 5.11.
Caution note Caution
The standard short forms listed in the preceding screenshot must be used.
Note Note
To use Chinese or another language with non-western characters, you must use the FlexPendant font, TpsFont, for any UI controls. It internally checks what language is currently active on the FlexPendant and uses the correct font for that language.

8

Copy the “strings.resx” file to the folder(s) created in the previous step.

9

The name of the file used for the foreign resources should be .<culture>.resx,, for example “strings.sv.resx" as in the following screenshot. Right click the file and rename it.

strings

10

Open the resource file and translate the texts in the value column. The name is the identity of the text and should remain the same.

Note Note
Obviously, texts might get longer or shorter when translated. You may therefore need to increase the sizes of some GUI controls when you have tested the application.
2 Prepare main project for localization

Follow these steps to add localization to your main project:

Step

Action

1

Add a reference to ABB.Robotics.Taf.Base in the main project.

2

In the TpsView attribute of the view class insert the name of the Texts dll like this:

[assembly: TpsView("ABB_MENU_TITLE_TXT","tpu-Operator32.gif","tpu-Operator16.gif", "TpsViewIRC5App.dll", "TpsViewIRC5App.TpsViewIRC5App", StartPanelLocation.Left, TpsViewType.Static,"TpsViewLocalizedAppTexts.dll", TpsViewStartupTypes.Manual)]

3

Declare a TpsResourceManager object at the top of the class as a private member variable and initialize it in the constructor.Add a call to an InitializeTexts method.

                //declaration
                private ABB.Robotics.Tps.Resources.TpsResourceManager _tpsRM;
                //constructor method
                _tpsRM = new ABB.Robotics.Tps.Resources.TpsResourceManager("TpsViewLocalizedApp.strings", ABB.Robotics.Taf.Base.TafAssembly.Load("TpsViewLocalizedAppTexts.dll"));
                InitializeComponent();
               InitializeTexts();
              
Note Note
The first constructor argument should be the name of your application with .strings as an added suffix. The second argument is the name of the assembly containing the resources.

4

Implement InitializeTexts(). Use the TpsResourceManager object and call GetString() using the identity (name) of the text you want as argument. Depending on the active language of the FlexPendant this call will retrieve the corresponding language resource.Example:Leave the contents of the method as it is, for example and so on.

Example

                InitializeTexts()
                {
                this.Label1.Text = _tpsRM.GetString("TXT_INSTR_LABEL");
                }
              

Leave the contents of the InitializeComponent method as it is, for example Label1.Text = "Signals" and so on.

5

The TpsResourceManager object has not yet been created when the application icon and title are to appear in the ABB menu, and therefore another technique must be used to have them correctly displayed. Add a resource name for the application title and a value in the resource file of each language. In the TpsView attribute the first argument is the application title. Replace it with the resource . It may look like this:

[assembly: TpsView("ABB_MENU_TITLE_TXT", ...,... TpsViewIRC5AppTexts.dll")]

The corresponding resource value will now be used. In case no resource is found the name will be used as is.

3 Build satellite assembly

Follow these steps to create a satellite assembly of the localized resx file:

Step

Action

1

The localized resource file should not be built with the ordinary build process, that is, the property Build Action should be set to “None". Right click on the strings.<culture>.resx file and select properties:

build assembly

2

You should now use the Visual Studio 2005 tool regen.exe to compile the resx file to a binary resource. After this the Visual Studio 2005 assembly linker tool al.exe should make a satellite assembly of the binary resource.

Read the following steps very carefully to make sure the satellite assembly is built correctly.

Note Note
Localization with Visual Studio 2008 has not yet been tested.

3

Create a post-build event in the Texts project in order to automate the building process.

Example: TpsViewLocalizedApp with resources in Swedish:

                mkdir ..\..\language
                mkdir ..\..\language\sv
                mkdir ..\..\language\sv\tps
                cd ..\..\sv\
                del *.resources
                del *.dll
                if exist strings.sv.resx (
                resgen strings.sv.resx TpsViewLocalizedApp.strings.sv .resources
                al /t:lib /embed:TpsViewLocalizedApp.strings.sv.resources /culture:en /out:TpsViewLocalizedAppTexts.resources.dll
                copy TpsViewLocalizedAppTexts.resources.dll ..\language\sv\tps\TpsViewLocalizedAppTexts.resources.dll)
              

post build event

The resgen command is written like this:

resgen strings.<culture> .resx <Namespace> .strings.<culture>.resources

where <culture>should be replaced with the correct language short form and <Namespace>should be replaced with the application namespace.

The al command takes the resulting dll located in the same directory as the resx file and makes a satellite assembly of it:

al /t:lib /embed:<Namespace>.strings.<culture>.resources /culture:en /out:<AssemblyNamee>.resources.dll

Note Note
The name of the satellite assembly will be the same for all localized languages. The third argument of the al command, culture:en, should be “en” . The reason is that the FlexPendant operating system has English as the underlying language.

4

It is necessary to ensure that the post-build step is executed with the correct versions of regen.exe and al.exe. The easiest way to do this is to use a Visual Studio 2005 Command prompt to build the project (or solution) or to start Visual Studio from that prompt.

First click Windows Start menu to launch the Command Prompt (at Programs > Microsoft Visual Studio 2005 > Visual Studio Tools). Then use the command devenv in order to start Visual Studio 2005. Now open your solution and build it. The post-build command is now guaranteed to execute with the correct settings.

Now open your solution and build it. The post-build command is now guaranteed to execute with the correct settings.

vs command prompt
Note Note

As default, Visual Studio will run post-build commands using the PC’s user settings (paths and so on). If you had Visual Studio 2003 installed earlier the post-build command is therefore very likely to use the wrong versions of resgen.exe and al.exe. The preceding procedure described guarantees that the Visual Studio 2005 versions are used.

(These can be found at: C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin/resgen.exe C:\WINNT\Microsoft.NET\Framework\v2.0.50727/al.exe).

4 Test a localized application

In order to test a localized application, the resources must be correctly organized in the file system of the controller. This should be done in the same way either the test is done on a virtual or a real FlexPendant. Follow these steps to test the application on a real FlexPendant:

Step

Action

1

Transfer, using an FTP client or the File Manager of RobotStudio, your application assemblies to the HOME directory of the active system. (TpsViewLocalizedAppTexts.dll, TpsViewLocalizedApp.gtpu.dll, TpsViewLocalizedApp.dll in the following screenshot).

2

Copy the language folder that was created by the post-build event to the HOME directory.

10.1 3 Languages Dir
Note Note
It is also possible to have both the assemblies and the language folder located under the SYSTEM folder one level up. The advantage of using HOME is that the files are included in a backup.

3

Verify that the language folder has folders for each language and that each tps folder have a .resources dll. If this is not the case, you need to go back to the post-build event of your Texts project and check what has gone wrong.

10.1 3b Languages Dir
Note Note
The name of the satellite assembly is the same for all languages, TpsViewLocalizedAppTexts.resources.dll in the preceding example.

4

Switch to another language (Control Panel - Languages) and restart the FlexPendant.

5

Verify that the name of your application in the ABB menu is correct.

6

Open the application and verify that the GUI texts are correctly displayed. Especially verify that text boxes, labels, listview columns and so on. are wide enough to display the translated texts.