Products Downloads


French version


 


This function returns a text which is located according to an alphanumeric key and the template execution locale.


The texts must be stored in a ".properties" file. The file name must correspond to a template name.


In a ".properties" file, each line contains the text/key pair following the key = text syntax.

Depending on the version of JDK used to run the APE, a ".properties" file can be encoded in two different ways:

  • if the JDK has a version earlier than 9 (mainly JDK 8), the ".properties" file must be encoded in ISO-8859-1 (Latin 1). The Unicode characters contained in the text must be entered in escape form (\uHHHH).
  • if the JDK has a version later than 9 (JDK 9 and later), the ".properties" file can be encoded UTF-8 or in ISO-8859-1 (Latin 1). In the latter case, the Unicode characters contained in the text must be entered in escape form (\uHHHH). If UTF-8 encoding is chosen, the encoding of the ".properties" file of the main template (if it exists) must also be in UTF-8 (UTF-8 and ISO-8859-1 encoding cannot be mixed).


A ".properties" file needs to be created for each execution locale supported by the template. The file name must satisfy the following syntax: "nameTemplate_language code_country or region code_variant.properties".


According to a locale value, the file search is performed as follows:

  1. "nameTemplate_language code_country or region code _variant.properties" file search,
  2. "nameTemplate_language code _country or region code.properties" file search,
  3. "nameTemplate_language code.properties" file search,
  4. "nameTemplate.properties" file search.


If the message function is called from a template which is not the main template (case of an imported or included template), the search is performed as follows:

  1. Search for the ".properties" file (according to the locale) with the name that corresponds to the current template name,
  2. If the key is not found in this file, we search the file with the name that corresponds to the main template name.


It is also possible to enter configurable texts. Each parameter is identified in the text by the syntax {N} or N corresponding to the parameter sequence number (N starts at 0) when calling the message. The parameters must be String, Number, Boolean or Date type.


Example of configurable text:

myTemplate_en.properties file

welcomePhrase=Welcome dear {0} {1}!

Template myTemplate.ftlx executed with the English (en) locale

${message(welcomePhrase, customerName, customerLastName) }



Parameters

String

msgKey

Unique key associated with the text to return

Mandatory

String/Number/Boolean/Date

params?

List of parameters (one or more) which will be inserted into the text to return

Optional



For example

${ hardisCore.message("title") }
<#assign label = hardisCore.message("designation", 123, "FRANCE")/>

↑ Top of page