Custom Component Strings
Appmixer lets you manage the components' inspector fields through the manifest or the strings object.
There are two ways how to customize component's strings:
Through a localization object inside the component's manifest
Adding custom strings to components namespace inside strings object
Component's manifest localization object
You can include custom strings inside the component's manifest using a localization object. The following is an example how to do it:
As you can see, there's a localization object at the end whose keys are language codes. This allows you to support multiple languages. Each value is an object whose keys are paths to the elements that will be customized (label, tooltip, placeholder, etc). The paths follow JSON path syntax.
You can customize the component's label and description. You can customize the component's input/output port labels, the inspector input field labels, and output variables as well.
There's a slightly different specification when localizing output variables. As you can see in the example, after outPorts[0].options
the next path fragment is the option's value, instead of the index. This is because the component could have a dynamic output instead and different output variables can share the same index, so we use the value to specify them instead.
To switch the language in UI, you call the Appmixer instance set
method:
Note that if you want to customize the whole UI, you must use this in conjunction with the strings object. Here's an example:
Strings object's component namespace
The alternative way to customize the component's strings is using the Strings Object. There is a root namespace components
which contains all the custom strings definitions for components:
Each key in components
object is the path to the component and the value is an object whose keys are the paths to elements (label, tooltip, placeholder, etc). This path follows the JSON path syntax. For more information about the Strings Object refer to the Custom Strings section.
service.json and module.json localization
Not only you can localize component's strings, but also services and modules. This allows you to change the label and description of the applications in the designer's left-side panel (the one you drag the applications from). To do it we can use either localization object in the service.json or module.json manifest or use the Strings Object.
Example using localization object in service.json
Example using Strings object
It follows the same pattern as in components, but we use the service/module path as a key for the definition:
Application groups localization
Labels of groups of application modules can be localized/changed without rewriting a single module.json file.
Use the localization strings to do so:
Strings resolving
When rendering the component's inspector, the strings are resolved with the following priority:
Localization object in the manifest (component.json).
Strings object components namespace.
Property in the manifest (component.json).
For example, when resolving an input's label, it will first look if there is a localization object in the manifest with a path to that input's label. If not, it will search the Strings Object. If none of that is defined, it will use values from the manifest.
Last updated