This is an internal documentation. There is a good chance you’re looking for something else. See Disclaimer.

Text-Resources

Text-Resources are used to allow localisation of labels. They are stored in properties files in the textresources subfolder of the model folder using the naming convention language_locale.properties.

Optional-Module Example: optional/modulename/resources/model/textresources/language_de.properties optional/modulename/resources/model/textresources/language_en.properties optional/modulename/resources/model/textresources/language_fr.properties optional/modulename/resources/model/textresources/language_it.properties

Customer-Module Example (Locales de and fr installed): customer/customername/resources/model/textresources/language_de.properties customer/customername/resources/model/textresources/language_fr.properties

Warning

In every textresources folder, each key must be on the same line in every textresource file available for the respective module.

Example content:

entities.Academic_title=Akad. Titel
client.entities.Academic_title=Akad. Titel
entities.Academic_title.label=Bezeichnung
entities.Academic_title.unique_id=Kürzel
entities.Academic_title.master_data=Stammdaten
entities.Academic_title.sorting=Sortierung

Different orthography for germany

Written German in Switzerland does not have an eszett (ß). That’s why we write “Abschliessen” where in Germany it should be “Abschließen”. The texts in language_de.properties are written in “Swiss” German. If certain texts are different in Germany, a second file language_de_DE.properties should be added. Individual texts from language_de.properties can be overwritten in this file. Not all lines from language_de.properties need to be copied because the file acts as a baseline and is partially overwritten by language_de_DE.properties. The order of the text resource keys should still be the same as in the baseline. If a country-specific module exists for a module, the text resource adjustments should be made in this module (See Country-specific Module).

Accessing Text-Resources

There are two ways of accessing Text-Resources. They can either be processed in the backend or directly accessed from the frontend. To allow access to Text-Resources in the client, the prefix client. needs to be prepended.

Entities, Relations and Forms

In Entities, Relations and Forms Textresources are automatically applied. For each entity, a client and a backend text-resource should be created as followed:

client.entities.Entity_name=Entity
entities.Entity_name=Entity

Each field should be labeled with a single text-resource:

entities.Entity_name.field_name=Field

Relations by default show the target-entity text-resource this can be overwritten by setting the the following text-resource:

entities.Entity_name.relRelation_name=Relation

If something different is needed, the label attribute can be used to set any text-resource.

Java

To use text-resources in Java, the TextResources service can be used. It can either return simple text-resources in the current locale or a given locale or format TextMessages. TextMessages are used for text-resources with placeholders.

private TextResources textResources;

//get a simple textresource
String localizedText = textResources.getText("entities.Entity_name.field");

To add a placeholder, it can be added in square brackets as followed:

entities.Room.clientquestion.delete.messagemulti=There are [number] other reservations for the linked event which take place in room [room]. Should the room also be removed from these reservations?

In this message, the number of “other reservations” and the label of the concerned room will be added in the java code that uses this resource.

private TextResources textResources;

//create a text message and format it
TextMessage message = new TextMessage("entities.Room.clientquestion.delete.messagemulti");
message.setVar("number", "100");
message.setVar("room", "Example Room");
String localizedText = textResources.formatTextMessage(message);

Java-Script

The getText function can be used to directly access text-resources which were prefixed with client. in java-script.

let localizedEntityName = getText("entities.Entity_name")

Placeholders in javascript are numbered and added in curly brackets.

client.dwr.failureMessageWithCode=Your input could not be processed (Error Code: {0}).

In this message the error code can be dynamically set.

To fill in the numbered placeholders, additional parameters can be passed to the getText function.

let failureMessage = getText("dwr.failureMessageWithCode", errorId)

Freemarker

Text-Resources can be loaded using the [@loadTextResource path="report.business_unit_dependency.moduleName"/] directive.