Skip to main content

Appendix B - Multilingual indexes

Multilingual indexes

Indexes in ADITO can support multilingual data for text-based fields. This document explains how to configure multilingual indexing using different translation modes and template processes. Multilingual support is available for index fields of type TEXT and TEXT_NO_STOPWORDS.

To enable multilingual indexing, set the property isMultiLanguage to true on a field of type TEXT or TEXT_NO_STOPWORDS.

Translation modes

The translationMode property defines how values are translated. It is only visible when isMultiLanguage is enabled. The following modes are available:

INTERN

Uses key-value pairs from your project's language packs. This is efficient and requires no runtime processing. Ensure the language packs are maintained and up-to-date.

STATIC

Uses a predefined in-memory key-value mapping provided by a mappingProcess. The $local.locale variable is available to determine the current target language. This method is fast but limited to predefined mappings. Very large mappings may consume excessive memory.

Structure:

{
"FIELDNAME1.value": {
"en": {
"Sales": "Sales",
"Support": "Support"
},
"de": {
"Sales": "Vertrieb",
"Support": "Unterstützung"
}
}
}

Example mappingProcess:

import { vars, result } from "@aditosoftware/jdito-types";

result.object({
"TESTFIELD1.value": {
"de": {
"Sales": "Vertrieb"
}
}
});

DYNAMIC

Invokes a translationProcess for each value and language. This is the most flexible mode and allows integration of external services, but it may reduce performance significantly. Use only when other modes are not feasible.

Example translationProcess:

import { translate, vars, result } from "@aditosoftware/jdito-types";

result.string(
translate.text(vars.get("$local.value"), vars.get("$local.locale"))
);
warning

The translation process is called for each field value and each language. Ensure the logic is optimized for high performance.

Template process

A templateProcess allows full control over the final indexed value for multilingual fields. It replaces both the field-level translationMode and the default value logic. This process is responsible for assembling the complete display value, including translating individual parts and formatting them as needed.

The process receives the current target language in $local.locale and can access each mapped record field by index, based on the configuration in indexFieldMappings of the IndexRecordContainer. These fields are injected into the template process as indexed parameters: {0}, {1}, {2}, etc.

Use this process when values must be composed from multiple fields, or when complex logic or external translation mechanisms are required.

Example templateProcess:

import { vars, translate, result } from "@aditosoftware/jdito-types";

var locale = vars.get("$local.locale");

result.string(
translate.text("Title", locale) + ": {1} | " +
translate.text("Test value", locale) + ": {0}"
);