public class LocalizationService
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.Locale |
DEFAULT_LOCALE |
static java.lang.String |
RHN_CUSTOM_DATEFORMAT |
static java.lang.String |
RHN_DB_DATEFORMAT
DateFormat used by RHN database queries.
|
Modifier and Type | Method and Description |
---|---|
java.util.SortedMap<java.lang.String,java.lang.String> |
availableCountries()
Get a SortedMap containing NAME/CODE value pairs.
|
java.util.SortedSet<java.lang.String> |
availablePrefixes()
Get a list of available prefixes and ensure that it is sorted by
returning a SortedSet object.
|
java.lang.String |
formatCustomDate(java.util.Date date)
Returns fixed custom format string displayed for the determined timezone
Example: 2010-04-01 15:04:24 CEST
|
java.lang.String |
formatDate(java.util.Date date)
Format the date and let the service determine the locale
|
java.lang.String |
formatDate(java.util.Date date,
java.util.Locale locale)
Format the date based on the locale and convert it to a String to
display.
|
java.lang.String |
formatNumber(java.lang.Number numberIn)
Format the Number based on the locale and convert it to a String to
display.
|
java.lang.String |
formatNumber(java.lang.Number numberIn,
int fractionalDigits)
Format the Number based on the locale and convert it to a String to
display.
|
java.lang.String |
formatNumber(java.lang.Number numberIn,
java.util.Locale localeIn)
Format the Number based on the locale and convert it to a String to
display.
|
java.lang.String |
formatNumber(java.lang.Number numberIn,
java.util.Locale localeIn,
int fractionalDigits)
Format the Number based on the locale and convert it to a String to
display.
|
java.lang.String |
formatShortDate(java.util.Date date)
Format the date as a short date depending on locale (YYYY-MM-DD in the
US)
|
java.lang.String |
formatShortDate(java.util.Date date,
java.util.Locale locale)
Format the date as a short date depending on locale (YYYY-MM-DD in the
US)
|
java.util.List<java.lang.String> |
getAlphabet()
Get alphabet list for callee's Thread's Locale
|
java.lang.String |
getBasicDate()
Use today's date and get it back localized and as a String
|
java.util.List<java.lang.String> |
getConfiguredLocales()
Returns the list of configured locales which is most likely a subset of
all the supported locales
|
java.lang.String |
getDebugMessage(java.lang.String messageId)
Get localized text for log messages as well as error emails.
|
java.util.List<java.lang.String> |
getDigits()
Get digit list for callee's Thread's Locale
|
static LocalizationService |
getInstance()
Get the running instance of the LocalizationService
|
java.lang.String |
getMessage(java.lang.String messageId)
Get a localized version of a String and let the service attempt to figure
out the callee's locale.
|
java.lang.String |
getMessage(java.lang.String messageId,
java.util.Locale locale)
Get a localized version of a string with the specified locale.
|
java.lang.String |
getMessage(java.lang.String messageId,
java.util.Locale locale,
java.lang.Object... args)
Get a localized version of a string with the specified locale.
|
java.lang.String |
getMessage(java.lang.String messageId,
java.lang.Object... args)
Get a localized version of a string with the specified locale.
|
java.lang.String[] |
getMessages(java.lang.String[] keys)
Take in a String array of keys and transform it into a String array of
localized Strings.
|
java.lang.String |
getPlainText(java.lang.String messageId)
Gets a Plain Text + localized version of a string with the default locale.
|
java.lang.String |
getPlainText(java.lang.String messageId,
java.lang.Object... args)
Gets a Plain Text + localized version of a string with the default locale.
|
java.util.List<java.lang.String> |
getSupportedLocales()
Get list of supported locales in string form
|
boolean |
hasMessage(java.lang.String messageId)
Simple util method to determine if the
|
protected void |
initService()
Initialize the set of strings and keys used by the service
|
boolean |
isLocaleSupported(java.util.Locale locale)
Determines if locale is supported
|
java.text.Collator |
newCollator()
Returns a NEW instance of the collator/string comparator
based on the current locale..
|
boolean |
reloadResourceFiles()
Reload the resource files from the disk.
|
public static final java.lang.String RHN_DB_DATEFORMAT
public static final java.lang.String RHN_CUSTOM_DATEFORMAT
public static final java.util.Locale DEFAULT_LOCALE
protected void initService()
public static LocalizationService getInstance()
public boolean reloadResourceFiles()
public java.lang.String getMessage(java.lang.String messageId)
messageId
- The key of the message we are fetchingpublic java.lang.String getMessage(java.lang.String messageId, java.util.Locale locale)
messageId
- The key of the message we are fetchinglocale
- The locale to use when fetching the stringpublic java.lang.String getMessage(java.lang.String messageId, java.lang.Object... args)
messageId
- The key of the message we are fetchingargs
- arguments for message.public java.lang.String getPlainText(java.lang.String messageId, java.lang.Object... args)
messageId
- The key of the message we are fetchingargs
- arguments for message.public java.lang.String getPlainText(java.lang.String messageId)
messageId
- The key of the message we are fetchingpublic java.lang.String[] getMessages(java.lang.String[] keys)
keys
- String[] array of key valuespublic java.lang.String getMessage(java.lang.String messageId, java.util.Locale locale, java.lang.Object... args)
messageId
- The key of the message we are fetchinglocale
- The locale to use when fetching the stringargs
- arguments for message.public java.lang.String getDebugMessage(java.lang.String messageId)
messageId
- The key of the message we are fetchingpublic java.lang.String formatDate(java.util.Date date)
date
- Date to be formatted.public java.lang.String formatShortDate(java.util.Date date)
date
- Date to be formattedpublic java.lang.String formatShortDate(java.util.Date date, java.util.Locale locale)
date
- Date to be formattedlocale
- Locale to use for formattingpublic java.lang.String getBasicDate()
public java.lang.String formatDate(java.util.Date date, java.util.Locale locale)
date
- Date to format.locale
- Locale to use for formatting.public java.lang.String formatCustomDate(java.util.Date date)
date
- Date to format.public java.lang.String formatNumber(java.lang.Number numberIn)
numberIn
- Number to format.public java.lang.String formatNumber(java.lang.Number numberIn, int fractionalDigits)
numberIn
- Number to format.fractionalDigits
- The number of fractional digits to use. This is
both the minimum and maximum that will be displayed.public java.lang.String formatNumber(java.lang.Number numberIn, java.util.Locale localeIn)
numberIn
- Number to format.localeIn
- Locale to use for formatting.public java.lang.String formatNumber(java.lang.Number numberIn, java.util.Locale localeIn, int fractionalDigits)
numberIn
- Number to format.localeIn
- Locale to use for formatting.fractionalDigits
- The maximum number of fractional digits to use.public java.util.List<java.lang.String> getAlphabet()
public java.util.List<java.lang.String> getDigits()
public java.util.SortedSet<java.lang.String> availablePrefixes()
public java.util.SortedMap<java.lang.String,java.lang.String> availableCountries()
{name=Spain, code=ES} {name=Sri Lanka, code=LK} {name=Sudan, code=SD} {name=Suriname, code=SR, } etc ...
public boolean hasMessage(java.lang.String messageId)
messageId
- we are searching forpublic java.util.List<java.lang.String> getSupportedLocales()
public java.util.List<java.lang.String> getConfiguredLocales()
public boolean isLocaleSupported(java.util.Locale locale)
locale
- user's localepublic java.text.Collator newCollator()