Retrieving content and translations
Interface api.repository.v1 provides mechanisms that allow dynamic retrieval of the contents of artifacts of type Content (TextContent) defined in the Eximee Designer module. This functionality is crucial when a script must return an error message, generate dynamic text for the user interface, or send a message to an external system, taking into account centralized multilingual mechanisms (i18n).
API methods
The process of retrieving a specific text consists of a chained call of three methods, which first locate the artifact itself, then select the appropriate language dictionary, and finally return the extracted plain text.
api.repository.v1.textContent(name, version)
Object
Finds an artifact with the specified name in the repository name and version version. Most often, the character "*" (meaning the latest available).
.language(langCode)
Object
Method called on the artifact object. It specifies a particular language code (e.g. "pl", "en").
.text()
String
Method called on the language object. Returns the target translated text value.
Error handling and missing artifact
When retrieving content, special caution is required, because the engine rigorously verifies the correctness and existence of identifiers.
Usage examples
1. Retrieving the optimistic variant (Happy Path)
If we are absolutely sure that a given artifact exists in the database and has been published in the specified language, we can use the shortened form.
2. Safe retrieval using try-catch blocks (Recommended solution)
In a production environment – especially when search keys or language codes are passed dynamically (e.g. based on a parameter from context or the user's profile preferences) – errors should always be safely caught. This allows a fallback text to be returned instead of interrupting the entire script.
Last updated
Was this helpful?
