org.xwiki.localization
Interface LocalizationManager


@Role
@Unstable
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 their priority. 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: c783001d5db075be9d7638a9e8ab635042695087 $

Method Summary
 Translation getTranslation(String key, Locale locale)
          Find a translation in the specified language.
 TranslationBundle getTranslationBundle(String bundleType, String bundleId)
          Find a bundle.
 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 language.

Parameters:
key - the key identifying the message to look for
locale - the locale of the target language
Returns:
the translation in the defined language
See Also:
LocalizationManager

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 identifier
TranslationBundleFactoryDoesNotExistsException - 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 identifier
TranslationBundleFactoryDoesNotExistsException - when no bundle factory could be found for the passed type


Copyright © 2004–2014 XWiki. All rights reserved.