Localizing a SmartComponent
This topic explains how to localize a previously created SmartComponent. If 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.
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%202024%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%202024%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\USER_NAME\Documents\Visual Studio version\Projects\BilingualSmartComponent\BilingualSmartComponent\BilingualSmartComponent.xml Added 'en' resources to BilingualSmartComponent Added 'es' resources to BilingualSmartComponent Created C:\Users\USER_NAME\Documents\...\BilingualSmartComponent.rslib
Note
It is possible to specify the resource base file name using the resources attribute. In the following example, the LibraryCompiler would search for resource files named Resource.en.xml, Resource.de.xml, etc.
<lc:LibraryCompiler xmlns:lc="urn:abb-robotics-robotstudio-librarycompiler" resources= "Resource"