Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Alpha5
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.common.i18n
Class I18n

    java.lang.Object
      org.modeshape.common.i18n.I18n

All Implemented Interfaces:
  I18nResource

    @ThreadSafe
    public final class I18n

extends Object
implements I18nResource

An internalized string object, which manages the initialization of internationalization (i18n) files, substitution of values within i18n message placeholders, and dynamically reading properties from i18n property files.

Method Summary
`static Set<Locale>` | `getLocalizationProblemLocales(Class<?> i18nClass)` Note, calling this method will not trigger localization of the supplied internationalization class.
`static Set<String>` | `getLocalizationProblems(Class<?> i18nClass)` Note, calling this method will not trigger localization of the supplied internationalization class.
`static Set<String>` | `getLocalizationProblems(Class<?> i18nClass, Locale locale)` Note, calling this method will not trigger localization of the supplied internationalization class.
`static LocalizationRepository` | `getLocalizationRepository()` Get the repository of localized messages.
`boolean` | `hasProblem()`
`boolean` | `hasProblem(Locale locale)`
`String` | `id()`
`static void` | `initialize(Class<?> i18nClass)` Initializes the internationalization fields declared on the supplied class.
`String` | `problem()`
`String` | `problem(Locale locale)`
`static void` | `setLocalizationRepository(LocalizationRepository localizationRepository)` Set the repository of localized messages.
`String` | `text(Locale locale, Object... arguments)` Get the localized text for the supplied locale, replacing the parameters in the text with those supplied.
`String` | `text(Object... arguments)` Get the localized text for the `current (default) locale`, replacing the parameters in the text with those supplied.
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Method Detail

### getLocalizationProblemLocales

    public static Set<Locale> getLocalizationProblemLocales(Class<?> i18nClass)

  Note, calling this method will not trigger localization of the supplied internationalization class.

  Parameters:
    `i18nClass` - The internalization class for which localization problem locales should be returned.
  Returns:
    The locales for which localization problems were encountered while localizing the supplied internationalization class; never `null`.

### getLocalizationProblems

    public static Set<String> getLocalizationProblems(Class<?> i18nClass)

  Note, calling this method will not trigger localization of the supplied internationalization class.

  Parameters:
    `i18nClass` - The internalization class for which localization problems should be returned.
  Returns:
    The localization problems encountered while localizing the supplied internationalization class to the default locale; never `null`.

### getLocalizationProblems

    public static Set<String> getLocalizationProblems(Class<?> i18nClass,
                                                      Locale locale)

  Note, calling this method will not trigger localization of the supplied internationalization class.

  Parameters:
    `i18nClass` - The internalization class for which localization problems should be returned.
    `locale` - The locale for which localization problems should be returned. If `null`, the default locale will be used.
  Returns:
    The localization problems encountered while localizing the supplied internationalization class to the supplied locale; never `null`.

### getLocalizationRepository

    public static LocalizationRepository getLocalizationRepository()

  Get the repository of localized messages. By default, this instance uses a `ClasspathLocalizationRepository` that uses this class' classloader.

  Returns:
    localizationRepository

### setLocalizationRepository

    public static void setLocalizationRepository(LocalizationRepository localizationRepository)

  Set the repository of localized messages. If `null`, a `ClasspathLocalizationRepository` instance that uses this class loader will be used.

  Parameters:
    `localizationRepository` - the localization repository to use; may be `null` if the default repository should be used.

### initialize

    public static void initialize(Class<?> i18nClass)

  Initializes the internationalization fields declared on the supplied class. Internationalization fields must be public, static, not final, and of type `I18n`. The supplied class must not be an interface (of course), but has no restrictions as to what class it may extend or what interfaces it must implement.

  Parameters:
    `i18nClass` - A class declaring one or more public, static, non-final fields of type `I18n`.

### id

    public String id()

  Returns:
    This internationalization object's ID, which will match both the name of the relevant static field in the internationalization class and the relevant property name in the associated localization files.

### hasProblem

    public boolean hasProblem()

  Returns:
    `true` if a problem was encountered while localizing this internationalization object to the default locale.

### hasProblem

    public boolean hasProblem(Locale locale)

  Parameters:
    `locale` - The locale for which to check whether a problem was encountered.
  Returns:
    `true` if a problem was encountered while localizing this internationalization object to the supplied locale.

### problem

    public String problem()

  Returns:
    The problem encountered while localizing this internationalization object to the default locale, or `null` if none was encountered.

### problem

    public String problem(Locale locale)

  Parameters:
    `locale` - The locale for which to return the problem.
  Returns:
    The problem encountered while localizing this internationalization object to the supplied locale, or `null` if none was encountered.

### text

    public String text(Object... arguments)

  Get the localized text for the `current (default) locale`, replacing the parameters in the text with those supplied.

  Specified by:
    `text` in interface `I18nResource`
  Parameters:
    `arguments` - the arguments for the parameter replacement; may be `null` or empty
  Returns:
    the localized text

### text

    public String text(Locale locale,
                       Object... arguments)

  Get the localized text for the supplied locale, replacing the parameters in the text with those supplied.

  Specified by:
    `text` in interface `I18nResource`
  Parameters:
    `locale` - the locale, or `null` if the `current (default) locale` should be used
    `arguments` - the arguments for the parameter replacement; may be `null` or empty
  Returns:
    the localized text

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Alpha5
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.