Package org.reldb.toolbox.il8n
Class Str
java.lang.Object
org.reldb.toolbox.il8n.Str
Message registry.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addTranslation(String language, String sourceFormat, String translatedFormat)
Add a format string translation for a given language.static void
addTranslations(String language, Map<String,String> sourceFormatToTranslatedFormat)
Set the source format string to target format string map for a given language.static String
Get the display language.static String
getTranslation(String sourceFormat)
Get a translation of a source format string for language returned by getDisplayLanguage().static String
getTranslation(String language, String sourceFormat)
Get a translation of a source format string for a given language.static String
Given a message containing a format specification per java.text.MessageFormat and optional arguments, return the string as its locale-specific, possibly-translated message.static void
setDisplayLanguage(String displayLanguage)
Set the display language.
-
Constructor Details
-
Str
public Str()
-
-
Method Details
-
setDisplayLanguage
Set the display language. Default is Locale.getDefault().getDisplayLanguage().- Parameters:
displayLanguage
- Language identifier, of the kind returned by Locale.getDefault().getDisplayLanguage().
-
getDisplayLanguage
Get the display language.- Returns:
- Language identifier, of the kind returned by Locale.getDefault().getDisplayLanguage().
-
addTranslations
public static void addTranslations(String language, Map<String,String> sourceFormatToTranslatedFormat)Set the source format string to target format string map for a given language.- Parameters:
language
- Language identifier, of the kind returned by Locale.getDefault().getDisplayLanguage().sourceFormatToTranslatedFormat
- A Map from source format strings defined in code to translated strings in the specified language.
-
addTranslation
Add a format string translation for a given language.- Parameters:
language
- Language identifier, of the kind returned by Locale.getDefault().getDisplayLanguage().sourceFormat
- Source format string, of the kind used by java.text.MessageFormat.translatedFormat
- Translated format string, of the kind used by java.text.MessageFormat.
-
getTranslation
Get a translation of a source format string for a given language.- Parameters:
language
- Language identifier, of the kind returned by Locale.getDefault().getDisplayLanguage().sourceFormat
- Source format string, of the kind used by java.text.MessageFormat.- Returns:
- Translated format string, of the kind used by java.text.MessageFormat.
-
getTranslation
Get a translation of a source format string for language returned by getDisplayLanguage().- Parameters:
sourceFormat
- Source format string, of the kind used by java.text.MessageFormat.- Returns:
- Translated format string, of the kind used by java.text.MessageFormat.
-
ing
Given a message containing a format specification per java.text.MessageFormat and optional arguments, return the string as its locale-specific, possibly-translated message.- Parameters:
formatSpecification
- Static specification of messagee format.arguments
- Message arguments.- Returns:
- Displayable message.
-