Package com.xpn.xwiki.web
Class XWikiMessageTool
- java.lang.Object
-
- com.xpn.xwiki.web.XWikiMessageTool
-
@Deprecated public class XWikiMessageTool extends Object
Deprecated.since 4.3M2 use theLocalizationManager
component insteadInternationalization 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 language requested. There are 3 sources where properties are looked for (in the specified order):- If there's a "documentBundles" property in the XWiki Preferences page then the XWiki documents listed there (separated by commas) are considered the source for properties
- If there's a "xwiki.documentBundles" property in the XWiki configuration file (xwiki.cfg) then the XWiki documents listed there (separated by commas) are considered for source for properties
- The Resource Bundle passed in the constructor
- Version:
- $Id: 30b72482859df5e179031ab5c7dacf865f35cca8 $
-
-
Field Summary
Fields Modifier and Type Field Description protected ResourceBundle
bundle
Deprecated.The default Resource Bundle to fall back to if no document bundle is found when trying to get a key.protected XWikiContext
context
Deprecated.
-
Constructor Summary
Constructors Constructor Description XWikiMessageTool(ResourceBundle bundle, XWikiContext context)
Deprecated.XWikiMessageTool(ContextualLocalizationManager localization)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
get(String key)
Deprecated.String
get(String key, Object... params)
Deprecated.Find a translation and then replace any parameters found in the translation by the passed parameters.String
get(String key, List<?> params)
Deprecated.Find a translation and then replace any parameters found in the translation by the passed params parameters.XWikiDocument
getDocumentBundle(String documentName)
Deprecated.Helper method to help get a translated version of a document.protected List<String>
getDocumentBundleNames()
Deprecated.Properties
getDocumentBundleProperties(XWikiDocument docBundle)
Deprecated.List<XWikiDocument>
getDocumentBundles()
Deprecated.List<XWikiDocument>
getDocumentBundles(String documentName, String defaultLanguage)
Deprecated.Helper method to help get a translated version of a document.protected String
getTranslation(String key)
Deprecated.Looks for a translation in the list of internationalization document bundles.protected XWikiContext
getXWikiContext()
Deprecated.
-
-
-
Field Detail
-
bundle
protected ResourceBundle bundle
Deprecated.The default Resource Bundle to fall back to if no document bundle is found when trying to get a key.
-
context
@Deprecated protected XWikiContext context
Deprecated.TheXWikiContext
object, used to get access to XWiki primitives for loading documents.
-
-
Constructor Detail
-
XWikiMessageTool
public XWikiMessageTool(ContextualLocalizationManager localization)
Deprecated.- Parameters:
localization
- the localization manager
-
XWikiMessageTool
public XWikiMessageTool(ResourceBundle bundle, XWikiContext context)
Deprecated.- Parameters:
bundle
- the default Resource Bundle to fall back to if no document bundle is found when trying to get a keycontext
- theXWikiContext
object, used to get access to XWiki primitives for loading documents
-
-
Method Detail
-
getXWikiContext
protected XWikiContext getXWikiContext()
Deprecated.
-
get
public String get(String key)
Deprecated.- Parameters:
key
- the key identifying the message to look for- Returns:
- the message in the defined language. The message should be a simple string without any parameters. If you
need to pass parameters see
get(String, java.util.List)
- See Also:
for more details on the algorithm used to find the message
-
get
public String get(String key, List<?> params)
Deprecated.Find a translation and then replace any parameters found in the translation by the passed params parameters. The format is the one used byMessageFormat
.Note: The reason we're using a List instead of an Object array is because we haven't found how to easily create an Array in Velocity whereas a List is easily created. For example:
$msg.get("key", ["1", "2", "3"])
.- Parameters:
key
- the key of the string to findparams
- the list of parameters to use for replacing "{N}" elements in the string. SeeMessageFormat
for the full syntax- Returns:
- the translated string with parameters resolved
-
get
public String get(String key, Object... params)
Deprecated.Find a translation and then replace any parameters found in the translation by the passed parameters. The format is the one used byMessageFormat
.- Parameters:
key
- the key of the string to findparams
- the list of parameters to use for replacing "{N}" elements in the string. SeeMessageFormat
for the full syntax- Returns:
- the translated string with parameters resolved
-
getDocumentBundleNames
protected List<String> getDocumentBundleNames()
Deprecated.- Returns:
- the list of internationalization document bundle names as a list of XWiki page names ("Space.Document") or an empty list if no such documents have been found
- See Also:
for more details on the algorithm used to find the document bundles
-
getDocumentBundles
public List<XWikiDocument> getDocumentBundles()
Deprecated.- Returns:
- the internationalization document bundles (a list of
XWikiDocument
) - See Also:
for more details on the algorithm used to find the document bundles
-
getDocumentBundle
public XWikiDocument getDocumentBundle(String documentName)
Deprecated.Helper method to help get a translated version of a document. It handles any exception raised to make it easy to use.- Parameters:
documentName
- the document's name (eg Space.Document)- Returns:
- the document object corresponding to the passed document's name. A translated version of the document for the current Locale is looked for.
-
getDocumentBundles
public List<XWikiDocument> getDocumentBundles(String documentName, String defaultLanguage)
Deprecated.Helper method to help get a translated version of a document. It handles any exception raised to make it easy to use.- Parameters:
documentName
- the document's name (eg Space.Document)defaultLanguage
- default language- Returns:
- the document object corresponding to the passed document's name. A translated version of the document for the current Locale is looked for.
-
getDocumentBundleProperties
public Properties getDocumentBundleProperties(XWikiDocument docBundle)
Deprecated.- Parameters:
docBundle
- the document bundle.- Returns:
- properties of the document bundle.
-
getTranslation
protected String getTranslation(String key)
Deprecated.Looks for a translation in the list of internationalization document bundles. It first checks if the translation can be found in the cache.- Parameters:
key
- the key identifying the translation- Returns:
- the translation or null if not found or if the passed key is null
-
-