Localizing a SmartComponent
This topic explains how to localize a previously-created SmartComponent. In case a SmartComponent hasn't been created yet, please read the corresponding sections for Creating and Building one.
As seen before, a smart component is created by parsing an XML file through ABB's LibraryCompiler. Additional resources can be included in the XML file, such as custom C# code and, most importantly for this topic, culture-specific information. This XML file contains a description of the SmartComponent, as well as a description of the properties and signals that compose it. For more information localization, as well as preferred practices, please consult Microsoft's Globalizing and Localizing .NET Framework Applications guide.
The LibraryCompiler automatically adds XML files as long as they adhere to the following naming convention:
nameOfSmartComponent.language.xml Where nameOfSmartComponent is the same name of the XML file processed by the LibraryCompiler, and language is the two-letter ISO-639 language code.
For instance, a SmartComponent called MyComp would have a localization file for German (de) called: MyComp.de.xml.
The steps that we will perform in this topic are the following:
- Create the default English XML localization file.
- Create an XML file called BilingualSmartComponent.es.xml for Spanish.
- Build the project using the LibraryCompiler (or with the Build Command inside Visual Studio).
Note
The following steps refers to the BilingualSmartComponent SmartComponent example, download the source code here.
Adding the localization resource files
Start by creating the default English XML localization file by following this template (BilingualSmartComponent.en.xml):
<?xml version="1.0" encoding="utf-8"?> <LibraryResource xmlns="urn:abb-robotics-robotstudio-libraryresource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:abb-robotics-robotstudio-libraryresource file:///C:\Program%20Files%20(x86)\ABB\SDK\RobotStudio%202020%20SDK\LibraryResourceSchema.xsd"> <SmartComponent name="BilingualSmartComponent" description="This smart component shows how easy it is to localize it just by adding an xml file"> <DynamicProperty name="SampleProperty" description="Sample Property Description"/> <IOSignal name="SampleSignal" description="Sample Signal Description"/> </SmartComponent> </LibraryResource>
Create an XML file called BilingualSmartComponent.es.xml since BilingualSmartComponent is the name of the SmartComponent and es is the language code for Spanish.
<?xml version="1.0" encoding="utf-8"?> <LibraryResource xmlns="urn:abb-robotics-robotstudio-libraryresource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:abb-robotics-robotstudio-libraryresource file:///C:\Program%20Files%20(x86)\ABB\SDK\RobotStudio%202020%20SDK\LibraryResourceSchema.xsd"> <SmartComponent name="BilingualSmartComponent" description="Este componente inteligente muestra lo fácil que es localizarlo con tan solo añadir un archivo xml"> <DynamicProperty name="SampleProperty" description="Propiedad de muestra"/> <IOSignal name="SampleSignal" description="Señal de muestra"/> </SmartComponent> </LibraryResource>
Build the project using the LibraryCompiler (or with the Build Command inside Visual Studio). The Build process should indicate that "en" and "es" resources have been added.
Compiling C:\Users\SEERVIE\Documents\Visual Studio 2015\Projects\BilingualSmartComponent\BilingualSmartComponent\BilingualSmartComponent.xml Added 'en' resources to BilingualSmartComponent Added 'es' resources to BilingualSmartComponent Created C:\Users\SEERVIE\Documents\...\BilingualSmartComponent.rslib
Note
It is possible to add the localization resource files even if they do not have the same name as the SmartComponent or if they exist in another directory. For this purpose, the <lc:Include> element can be used as in the main XML file as shown below:
<?xml version="1.0" encoding="utf-8" ?>
<lc:LibraryCompiler xmlns:lc="urn:abb-robotics-robotstudio-librarycompiler"
xmlns="urn:abb-robotics-robotstudio-graphiccomponent"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:abb-robotics-robotstudio-librarycompiler file:///C:\Program%20Files%20(x86)\ABB\SDK\RobotStudio%202020%20SDK\LibraryCompilerSchema.xsd
urn:abb-robotics-robotstudio-graphiccomponent file:///C:\Program%20Files%20(x86)\ABB\SDK\RobotStudio%202020%20SDK\GraphicComponentSchema.xsd">
<lc:Include source ="MY_PATH/MY_FILE_1.xml"/>
<lc:Include source ="OTHER_PATH/MY_FILE_2.xml"/>
<lc:Library fileName="BilingualSmartComponent.rslib">
<lc:DocumentProperties>
<lc:Author>SEERVIE</lc:Author>
<lc:Image source="BilingualSmartComponent.png"/>
<!--
File continues
.
.
.
-->
Caution
Please observe that the last code snippet only shows a fraction of the complete file to show the correct
location and use of the <lc:Include>
elements.