Language support
Language support (translations) is required if the login page generator directly transforms the GUI descriptor and makes unaltered use of the label attributes. Either nevisAuth or nevisLogRend can perform translations. The mechanism (handled by the AuthEngine) works as follows:
- Check, if the language support is enabled (useLiteralDictionary=true).
- Detect the language required by the user. The following sources are checked:
- Translate each label attribute in the GUI descriptor by looking up the value in the dictionary. If the element represents an error message and there is no match, search for the label value with whitespaces replaced by underscores "" or a label "error_X", where _X is the error code. If there is no match, the current value remains.
This mechanism is used for simple setups where the login page renderer (e.g., the one built-in in nevisProxy) only performs a simple transformation (from XML to HTML). For more advanced setups, the nevisLogRend component should be used instead and the useLiteralDictionary should be set to false.
The translations are defined in the LitDict files in the conf directory of the nevisAuth instance: /var/opt/nevisauth/<instance>/conf/LitDict
.properties.*
Literal dictionary support is turned off per default (if not configured) and is enabled in the default configuration template, delivered with the package.
The translation literals may contain any code that the login renderer accepts. If Web pages are displayed with nevisLogRenderer, regular HTML tags can be inserted. Example:
Enter your <b>PIN number</b> and <br/> confirm that you have read and understood the disclaimer.
Parametrized translation texts
It is possible to construct complex translation texts using parametrized literals and annotated labels.
Given a configured literal
paramText=Mary had a little {1} whose {2} was {3} as {4}
the label
paramText[lamb][fleece][white][snow]
will translate to
Mary had a little lamb whose fleece was white as snow
This mechanism uses Java's MessageFormat class. Note that this class treats single quotes as special signs. To use single quotes in parametrized translation texts, you have to escape them with quotes. So " ' ' " will display as a single quote.
Translations using recursive variable resolution
It is also possible to construct complex translation texts by including variable expressions in the translation. Above example can also be written as
paramText=Mary had a little ${notes:animal} whose {inargs:propertyName} was ${notes:color} as ${...}.
This assumes that the variables notes:animals, inargs:propertyNames and notes:color are set at the time the translation text is resolved.
Using LitDicts that are not ISO-8859-1 encoded
To load LitDict property files that are not ISO-8859-1 charset encoded, you can set the system property ch.nevis.esauth.litdict.charset.encoding to the desired charset, e.g., UTF-8.