Class I18nService
java.lang.Object
fr.paris.lutece.portal.service.i18n.I18nService
This class provides services for internationalization (i18n)
- Since:
- v1.4.1
-
Method Summary
Modifier and TypeMethodDescriptionReturns supported locales for Lutece backofficestatic ReferenceListgetAdminLocales(Locale locale) Returns a ReferenceList of available localesstatic StringgetDateFormatShortPattern(Locale locale) Get the short date format specified by a localestatic LocaleGet the default Locale specified in properties filestatic StringgetLocalizedDate(Date date, Locale locale, int nDateFormat) Format a date according to the given localestatic StringgetLocalizedDateTime(Date date, Locale locale, int nDateFormat, int nTimeFormat) Format a date according to the given localestatic StringgetLocalizedString(String strKey, Object[] arguments, Locale locale) Returns the string corresponding to a given key for a given locale that use a MessageFormat pattern with arguments.static StringgetLocalizedString(String strKey, Locale theLocale) Returns the string corresponding to a given key for a given locale
Core key structure :
portal.[admin, features, insert, rbac, search, site, style, system, users, util].keyPlugin key structure :
[plugin].keyModule key structure :
module.[plugin].[module].keystatic Enumeration<String>getPluginBundleKeys(String strPluginName) returns the resource bundle keys of a pluginstatic StringThis method localize a string.static <E extends Localizable>
Collection<E>localizeCollection(Collection<E> collection, Locale locale) Localize in place all items of a collectionstatic <E extends Localizable>
List<E>localizeCollection(List<E> list, Locale locale) Localize in place all items of a liststatic voidReset the caches
-
Method Details
-
localize
This method localize a string. It scans for localization keys and replace them by localized values.
The localization key structure is : #{bundle.key}.
bundle's values should be 'portal' or a plugin name.- Parameters:
strSource- The string that contains localization keyslocale- The locale- Returns:
- The localized string
-
getLocalizedString
Returns the string corresponding to a given key for a given locale
- Core key structure :
portal.[admin, features, insert, rbac, search, site, style, system, users, util].key - Plugin key structure :
[plugin].key - Module key structure :
module.[plugin].[module].key
- Parameters:
strKey- The key of the stringtheLocale- The locale- Returns:
- The string corresponding to the key
- Core key structure :
-
getLocalizedString
Returns the string corresponding to a given key for a given locale that use a MessageFormat pattern with arguments.- Parameters:
arguments- The arguments used as values by the formatterstrKey- The key of the string that contains the patternlocale- The locale- Returns:
- The string corresponding to the key
-
getLocalizedDate
Format a date according to the given locale- Parameters:
date- The date to formatlocale- The localenDateFormat- A DateFormat constant corresponding to the expected format. (ie: DateFormat.FULL)- Returns:
- The formatted date
-
getLocalizedDateTime
public static String getLocalizedDateTime(Date date, Locale locale, int nDateFormat, int nTimeFormat) Format a date according to the given locale- Parameters:
date- The date to formatlocale- The localenDateFormat- A DateFormat constant corresponding to the expected format. (ie: DateFormat.FULL)nTimeFormat- A TimeFormat constant corresponding to the expected format. (ie: DateFormat.SHORT)- Returns:
- The formatted date
-
getAdminAvailableLocales
Returns supported locales for Lutece backoffice- Returns:
- A list of locales
-
getDefaultLocale
Get the default Locale specified in properties file- Returns:
- The default Locale
-
getDateFormatShortPattern
Get the short date format specified by a locale- Parameters:
locale- The locale- Returns:
- The localized short date pattern or null else
-
getAdminLocales
Returns a ReferenceList of available locales- Parameters:
locale- The locale to display available languages- Returns:
- A ReferenceList of available locales
-
localizeCollection
public static <E extends Localizable> Collection<E> localizeCollection(Collection<E> collection, Locale locale) Localize in place all items of a collection- Type Parameters:
E- the type of the elements of the collection- Parameters:
collection- The collection to localizelocale- The locale- Returns:
- The localized collection passed as argument
-
localizeCollection
Localize in place all items of a list- Type Parameters:
E- the type of the elements of the list- Parameters:
list- The list to localizelocale- The locale- Returns:
- The localized collection passed as argument
-
resetCache
public static void resetCache()Reset the caches- Since:
- 5.1
-
getPluginBundleKeys
returns the resource bundle keys of a plugin- Parameters:
strPluginName-- Returns:
- the enumeration
-