'translations': Customising and Translating Strings in Lycia LowCode

'translations' Setting Overview

List of Lycia LowCode Messages

Public Localization Functions LSTRS(), LSTRT(), LSTRC()

'translations' Setting Overview

Note: Before proceeding, get acquainted with the Settings Levels section of LyciaLowCode Settings page (the concept of levels is essential for configuring multiple interactions and the multitable support).

The definitions like LET <setting_variable>.<setting_name> = <value> refer to the InteractForm_Settings level, while LET <setting_variable>.views["<db_table_name>"].<setting_name> = <value> refers to the View level.

This setting can be defined for:

InteractForm_Settings level: Yes

View level: No

translations is an optional property, used to localize errors and messages produced by LowCode applications. This feature facilitates an easy customization and localization of strings, such as prompts, labels, and confirmation messages. This is particularly useful for customizing standard form messages like "Yes", "No", "Cancel", or confirmation prompts generated by Lycia LowCode.

This comes in a form of a map of translations, and is a HASHMAP of STRING. The key of the HASHMAP is the original string, and the value is the customized / localized string:

LET <settings_var>.translations["<original_string>"] = "<localized_string>"

Example:

LET settings.translations["Do you really want to delete this item?"] = "Möchten Sie diesen Artikel wirklich löschen?"

This setup offers several advantages:

By using these features efficiently, developers can create multilingual applications that cater to a global audience, improving usability and user satisfaction.

Example program:

DATABASE cms_llc

IMPORT FGL lib_llc_interact_form

GLOBALS "../../../lib_llc_interact_form/llc_interact_form.4gl"

 

MAIN

 

DEFINE form_settings InteractForm_Settings -- Initialize form settings

 

INITIALIZE form_settings.* TO NULL

 

LET form_settings.form_file = 'hello_alch_test'

LET form_settings.confirm_accept = 1

LET form_settings.confirm_cancel = 1 -- Define custom translations

LET form_settings.translations["Modify"] = "Змінити"

LET form_settings.translations["Do you want to save changes?"] = "Ви бажаєте зберегти зміни?"

LET form_settings.translations["Yes"] = "Так"

LET form_settings.translations["No"] = "Ні"

LET form_settings.translations["Cancel"] = "Відмінити" -- Call the form with customized settings

 

CALL InteractForm(form_settings)

 

END MAIN

 

Return to top

 

List of Lycia LowCode Messages

Here is the list of internal LowCode messages that can be provided as original strings to the .translations setting.

Note: The %1 notation serves as a placeholder used with the SFMT() operator.

 

Return to top

Public Localization Functions LSTRS(), LSTRT(), LSTRC()

Additionally, LowCode provides the public localization functions LSTRS(), LSTRT(), and LSTRC() to handle the localization of various types of strings programmatically. These methods provide extended capabilities for translating strings, table names, and column / field names. They enhance the standard Lycia LSTR() function by adding specific search mechanisms tailored for use within applications with Lycia LowCode if no translation is found in the internal engine. They integrate with the internal translation engine, user-defined mappings, and UI components to deliver a human-readable, localized experience.

LSTRS Method: Translating Strings

The LSTRS method is designed to translate input strings, including messages and general text. It follows a specific sequence to locate the translation:

1. Search for a translated string in the map translations of the InteractForm object (or it was set in InteractForm_Settings);

2. Search for a translated string using the Lycia function LSTR().

Example:

-- Assuming InteractForm_Settings.translations["Submit"] = "Enviar"

DISPLAY iForm.LSTRS("Submit")  -- Returns "Enviar" based on the InteractForm settings

LSTRT Method: Translating Table Names

The LSTRT method translates a table name into a human-readable format, following this sequence:

1. Search for a translated string in the map translations of the InteractForm object (or it was set in InteractForm_Settings). It will search in the form for the defined alias $human$<table_name> and get the tableName property of this alias. For instance, iForm.LSTRT("activity") will look for the alias below in the form and return CMS Contact Activity:

<form.database>

<Database name="cms">

<Database.dbTables>

<DbTable tableName="CMS Contact Activity" alias="$human$activity" />

</Database.dbTables>

</Database>

</form.database>

2. Search for a translated string using Lycia function LSTR().

LSTRC Method: Translating Column / Field Names

The LSTRC method translates the input field_name to the human-readable name. It uses the following sequence:

1. Search for a translated string in the map translations of the InteractForm object (or it was set in InteractForm_Settings). It will search for the label with the identifier lb_<field_name> in the form and get the Text of this label. For instance, iForm.LSTRC("cont_name") will look for the label lb_cont_name in the form below and return Contact Name:

<Label text="Contact Name" fieldTable="" identifier="lb_cont_name"/>

<TextField fieldTable="contact" identifier="cont_name"/>

2. Search in the form for the parent TableColumn of the input field and get the Text of this table column. For example, iForm.LSTRC("cont_name") will look for the TableColumn in the form below and return Contact Name:

<TableColumn text="Contact Name" identifier="clm_cont_name" >

<TextField fieldTable="contact" identifier="cont_name"/>

</TableColumn>

3. Search for a translated string using Lycia function LSTR().

Caching Translations

Once a translation is found using any of the aforementioned methods, it is stored in the translations property of the InteractForm object. Subsequent calls to LSTRS(), LSTRT(), or LSTRC() for the same identifier will directly use the cached translation.

Summary

These methods provide an extended layer of localization for applications with Lycia LowCode, ensuring flexibility and precision in translating UI elements and messages. They build upon Lycia's LSTR() function while adding custom search paths to accommodate LowCode-specific configurations and data structures.

 

Return to top

 

Contact Us

Privacy Policy

Copyright © 2025 Querix, (UK) Ltd.