In this example, we are going to be using mappers to translate our language to code.
We are going to start by adding a new transformer. Go to Transformers and then click on the + icon. Then give the Transformer a recognizable Name and Description. The Identifier will be created automatically.
Then under Settings, search for Data, transform data using mappers and conditions. You can do this by scrolling down, or enter a search criteria in the input field.
After that, add a new Transformer by pressing + Add transformers.
Search for Value mapper.
This transformer will be able to apply mappers on the value of nodes in our entity based on accessors and mappers. We need to select our language node first. So start of by selecting the Pattern accessor in the accessor field. For the pattern use the value language. Now we can start adding mappers.
Add a new mapper by clicking the Add mappers button. The dropdown of the mappers is quite extensive. When opening the dropdown, you can start typing to find a mapper. Search for the Dictionary map and select it. This will show the form that is required for this mapper. Because we want to compare our values when mapping them, we are going to select the Equals Comparator from the dropdown. This will tell the system to only map values when the from value will match exactly. If we were to select the Not equals comparator here, it would only map the value if it did not match the from value.
To tell Alumio which values to map to which value, we need to create the Map. Click on the Add map button to start. This will show a form with 2 new fields. This is a set for a map. The first value is the from value. The second field is the to field. If the value matches the from value, Alumio will replace the value with the connected to value. Because our from value is an integer, select number from the first dropdown. The value should be 1. Because we want to map the value from 1 to an actual language code, we need to setup the to value. The value type for this value is string. The value for this example will be en_US.
We can now test the transformer by clicking the Test button. The result of the transformer will be the following:
To ensure our map is working, we can add an additional from to pair. For this pair, we are translating 2 to the value en_GB. If we click Test again, the result will not change. So in the transformer tester input field, change the language value to 2 and then click the Test button again.
The value should now be mapped differently.
To continue to the next step, we are going to remove our transformer configuration. Click on the cross next to the Value mapper dropdown. This will remove all the configuration for our transformer.