public interface Translator
This is more like a dictionary where the key is the original English text.
Modifier and Type | Method and Description |
---|---|
java.lang.String |
translate(java.lang.String key)
looks up a translated string from the currently selected language
dictionary,
|
java.lang.String translate(java.lang.String key)
If the key is not found in the dictionary this returns the key, in this way the source code can contain full English texts for buttons etc which will then be used in the user interface if the translation is not available.
If the key starts with '!' the key is not translated, instead the rest of the key is returned as the value of this function. This is a way to prevent translation (attempts) of strings, such as file system paths by prepending them with exclamation marks.
If the key is not found in the dictionary and they key ends with '/' then rest of the key (including the '/') marker is stripped and the stripped string is returned. This allows two (or more) superficially similar words to have different translations in the dictionary by appending a differentiating tag to the key.
If a '/' slash character is needed in the untranslated English text (i.e. in the key) it needs to be duplicated.
The underlying dictionary is backed by a Java Properties file.
To comply
with that the key is internally converted so that the ' '
,
':'
, '='
and '#'
characters are preceded with
the '\ยด
backslash and characters outside the ASCII range of
32..126 (i.e. classic printable characters) are converted to Unicode
escapes of the form \\uxxxx
. This has no effect on the key i.e.
texts in the source code but needs to be kept in mind when the backing
properties file is generated.
key
- the English word (or text) to be localized