Package org.hl7.fhir.utilities.i18n
Class I18nBase
- java.lang.Object
-
- org.hl7.fhir.utilities.i18n.I18nBase
-
- Direct Known Subclasses:
RenderingI18nContext
public abstract class I18nBase extends Object
Handles the locale, ResourceBundle and String formatting for i18n This abstract class should be extended when implementing a IWorkerContext Interface.
-
-
Field Summary
Fields Modifier and Type Field Description static StringKEY_DELIMITERprotected Localelocalestatic StringPLURAL_SUFFIX
-
Constructor Summary
Constructors Constructor Description I18nBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringformatMessage(String theMessage, Object... theMessageArguments)Formats the given message, if needed, with the passed in message arguments.StringformatMessagePlural(Integer plural, String theMessage, Object... theMessageArguments)Formats the message with locale correct pluralization using the passed in message arguments.LocalegetLocale()protected StringgetMessagesSourceFileName()protected StringgetPluralKey(Integer number, String baseKey)protected Set<String>getPluralKeys(String baseKey)protected Set<String>getPluralSuffixes()protected StringgetRootKeyFromPlural(String pluralKey)booleanisWarnAboutMissingMessages()protected booleanmessageKeyExistsForLocale(String message)voidsetLocale(Locale locale)voidsetPluralRules(Locale locale)voidsetValidationMessageLanguage(Locale locale)Loads the correspondingResourceBundlefor the passed inLocale.voidsetWarnAboutMissingMessages(boolean warnAboutMissingMessages)protected StringtypeOfString()
-
-
-
Field Detail
-
PLURAL_SUFFIX
public static final String PLURAL_SUFFIX
- See Also:
- Constant Field Values
-
KEY_DELIMITER
public static final String KEY_DELIMITER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
I18nBase
public I18nBase()
-
-
Method Detail
-
typeOfString
protected String typeOfString()
-
messageKeyExistsForLocale
protected boolean messageKeyExistsForLocale(String message)
-
formatMessage
public String formatMessage(String theMessage, Object... theMessageArguments)
Formats the given message, if needed, with the passed in message arguments.- Parameters:
theMessage- Base message to format.theMessageArguments- Placeholder arguments, if needed.- Returns:
- The formatted, internationalized,
String
-
getPluralKey
protected String getPluralKey(Integer number, String baseKey)
-
getPluralKeys
protected Set<String> getPluralKeys(String baseKey)
-
getPluralSuffixes
protected Set<String> getPluralSuffixes()
-
getRootKeyFromPlural
protected String getRootKeyFromPlural(@Nonnull String pluralKey)
-
formatMessagePlural
public String formatMessagePlural(Integer plural, String theMessage, Object... theMessageArguments)
Formats the message with locale correct pluralization using the passed in message arguments. In the message properties files, each plural specific message will have a key consisting of a root key and a suffix denoting the plurality rule (_one for singular, _other for multiple in English, for example). Suffixes are provided by th ICU4J library from unicode.org- Parameters:
plural- The number that indicates the plurality of the phrasetheMessage- the root key of the phrase.theMessageArguments- Placeholder arguments, if needed.- Returns:
- The formatted, internationalized,
String
-
setValidationMessageLanguage
public void setValidationMessageLanguage(Locale locale)
Loads the correspondingResourceBundlefor the passed inLocale.- Parameters:
locale-Localeto load resources for.
-
getMessagesSourceFileName
protected String getMessagesSourceFileName()
-
setPluralRules
public void setPluralRules(Locale locale)
-
isWarnAboutMissingMessages
public boolean isWarnAboutMissingMessages()
-
setWarnAboutMissingMessages
public void setWarnAboutMissingMessages(boolean warnAboutMissingMessages)
-
-