9 Localizing a FlexPendant application. ABB RobotWare 5.0
Robot Application Builder (RAB) is a software tool, which enables ABB programmers to develop customized operator interfaces for the IRC5 robot controller. Robot Application Builder is fully integrated with Microsoft Visual Studio, which means that a .NET programmer will recognize wizards for project setup, tools for visual design support, and debug etc.
Advertisement
Advertisement
9 Localizing a FlexPendant application
8.2.2. Troubleshooting
9 Localizing a FlexPendant application
3HAC028083-001 Revision: D 299
9 Localizing a FlexPendant application
9.1. Adding support for several languages
9.1. 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 RAB applications.
This enables customized applications to be presented in the active language of the
FlexPendant, i.e. 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!
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 Project and name the project <YourAppName>Texts.
NOTE!
Both projects should belong to the same solution. The application will now compile to three assemblies: <YourAppName>.dll , <YourAppName>.gtpu.dll and <YourApp-
Name>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:
300
10.1_5
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).
Continues on next page
3HAC028083-001 Revision: D
9 Localizing a FlexPendant application
9.1. Adding support for several languages
Continued
Step Action
6. Open the resource file and add name and value for the texts of the default language.
Use capital letters in the name column.
6.5.1_1
7. In the Texts project create a folder with the culture short form as name, e.g. de for
German and sv for Swedish.
10.1_6
NOTE!
Russian (ru) has been added in RW/RAB 5.11.
CAUTION!
The standard short forms listed above must be used.
NOTE!
To be able 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.
3HAC028083-001 Revision: D
Continues on next page
301
9 Localizing a FlexPendant application
9.1. Adding support for several languages
Continued
Step Action
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 strings.<culture>.resx, e.g. “strings.sv.resx" as in the picture below. Right click the file and rename it.
10.1_4
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!
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)]
302
Continues on next page
3HAC028083-001 Revision: D
9 Localizing a FlexPendant application
9.1. Adding support for several languages
Continued
Step Action
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("TpsVi ewLocalizedApp.strings",
ABB.Robotics.Taf.Base.TafAssembly.Load("TpsViewLocal izedAppTexts.dll"));
InitializeComponent();
InitializeTexts();
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:
InitializeTexts()
{ this.Label1.Text = _tpsRM.GetString("TXT_INSTR_LABEL");
}
Leave the contents of the
InitializeComponent
method as it is, e.g.
Label1.Text = "Signals"
etc.
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 name. 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.
3HAC028083-001 Revision: D
Continues on next page
303
9 Localizing a FlexPendant application
9.1. Adding support for several languages
Continued
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, i.e. the property Build Action should be set to “None". Right click on the strings.<cul-
ture>.resx file and select properties:
6.5.1_4
2. You should now use the Visual Studio 2005 tool resgen.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!
Localization with Visual Studio 2008 has not yet been tested.
304
Continues on next page
3HAC028083-001 Revision: D
9 Localizing a FlexPendant application
9.1. Adding support for several languages
Continued
Step Action
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.resource
s.dll)
10.1_9
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:<AssemblyName>.resources.dll
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.
3HAC028083-001 Revision: D
Continues on next page
305
9 Localizing a FlexPendant application
9.1. Adding support for several languages
Continued
Step Action
4. It is necessary to ensure that the post-build step is executed with the correct versions of resgen.exe and al.exe. The easiest way to do this is to use a VS 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 VS 2005.
Now open your solution and build it. The post-build command is now guaranteed to execute with the correct settings.
6.5.1_5
NOTE!
As default, Visual Studio will run post-build commands using the PC’s user settings
(paths etc.). If you had VS 2003 installed earlier the post-build command is therefore very likely to use the wrong versions of resgen.exe and al.exe. The procedure described above guarantees that the VS 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. (TpsViewLocalizedApp-
Texts.dll, TpsViewLocalizedApp.gtpu.dll, TpsViewLocalizedApp.dll in the picture below).
306
Continues on next page
3HAC028083-001 Revision: D
9 Localizing a FlexPendant application
9.1. Adding support for several languages
Continued
Step Action
2. Copy the language folder that was created by the post-build event to the HOME directory.
10.1_3
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
NOTE!
The name of the satellite assembly is the same for all languages, TpsViewLocal-
izedAppTexts.resources.dll in the example above.
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.
3HAC028083-001 Revision: D
Continues on next page
307
9 Localizing a FlexPendant application
9.1. Adding support for several languages
Continued
Step Action
6. Open the application and verify that the GUI texts are correctly displayed. Especially verify that text boxes, labels, listview columns etc. are wide enough to display the translated texts.
308 3HAC028083-001 Revision: D
Download
Advertisement
Key features
Develop custom operator interfaces
FlexPendant SDK
PC SDK
Visual Studio integration
.NET programming
Virtual IRC5
Frequently asked questions
Robot Application Builder (RAB) is a software tool, which enables programmers to develop customized operator interfaces for the IRC5 robot controller.
The supported operating systems are Microsoft Windows XP + SP2 or Windows Vista + SP1.
The supported versions are Visual Studio 2005 and Visual Studio 2008.
The supported programming languages are C# and Visual Basic.NET for FlexPendant applications. For PC applications, any of the .NET languages should work, however, ABB support is only offered for Visual Basic and C#.