Package org.xwiki.localization
Interface LocalizationManager
-
@Role public interface LocalizationManager
Internationalization service based on key/property values. The key is the id of the message being looked for, and the returned value is the message in the specified language.Properties are looked for in several
bundles
, in the order of theirpriority
. The first translation found in one of these bundles is the one returned. If the property is not found in any of these sources, then null is returned.- Since:
- 4.3M2
- Version:
- $Id: c74d10b13de04edcd32bdc35d8b9b336e38241d1 $
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Locale
getDefaultLocale()
Translation
getTranslation(String key, Locale locale)
Find a translation in the specified locale.TranslationBundle
getTranslationBundle(String bundleType, String bundleId)
Find a bundle.default String
getTranslationPlain(String key, Locale locale, Object... parameters)
Find a translation in the current language.void
use(String bundleType, String bundleId)
Registers a resource location as a possible localization bundle that should be used in the current execution.
-
-
-
Method Detail
-
getTranslation
Translation getTranslation(String key, Locale locale)
Find a translation in the specified locale.- Parameters:
key
- the key identifying the message to look forlocale
- theLocale
for which this translation is searched. The result might me associated to a differentLocale
(for example getting thefr
translation when asking for thefr_FR
one).- Returns:
- the translation in the defined language
- See Also:
LocalizationManager
-
getTranslationPlain
default String getTranslationPlain(String key, Locale locale, Object... parameters)
Find a translation in the current language.- Parameters:
key
- the key identifying the message to look forlocale
- theLocale
for which this translation is searched. The result might me associated to a differentLocale
(for example getting thefr
translation when asking for thefr_FR
one).parameters
- the parameters- Returns:
- the translation in the current language rendered as plain text, null if no translation could be found
- Since:
- 14.1RC1, 13.10.3
- See Also:
getTranslation(String, Locale)
-
getTranslationBundle
TranslationBundle getTranslationBundle(String bundleType, String bundleId) throws TranslationBundleDoesNotExistsException, TranslationBundleFactoryDoesNotExistsException
Find a bundle.- Parameters:
bundleType
- a hint identifying the bundle type.bundleId
- the identifier of the bundle, for example a wiki document name, or the URL to a.properties
file.- Returns:
- the
TranslationBundle
or null if none could be found - Throws:
TranslationBundleDoesNotExistsException
- when no bundle could be found for the passed identifierTranslationBundleFactoryDoesNotExistsException
- when no bundle factory could be found for the passed type- Since:
- 4.5M1
-
use
void use(String bundleType, String bundleId) throws TranslationBundleDoesNotExistsException, TranslationBundleFactoryDoesNotExistsException
Registers a resource location as a possible localization bundle that should be used in the current execution. The order in which resource of the same type are considered when searching for a translation corresponds to the order in which they were pulled. Each execution (generally a client request) has its own list of pulled resources, and at the end of an execution, its list of pulled resources is cleared.- Parameters:
bundleType
- a hint identifying the bundle type.bundleId
- the identifier of the bindle, for example a wiki document name, or the URL to a.properties
file.- Throws:
TranslationBundleDoesNotExistsException
- when no bundle could be found for the passed identifierTranslationBundleFactoryDoesNotExistsException
- when no bundle factory could be found for the passed type
-
-