Class NLS

java.lang.Object
org.eclipse.jgit.nls.NLS

public class NLS extends Object
The purpose of this class is to provide NLS (National Language Support) configurable per thread.

The setLocale(Locale) method is used to configure locale for the calling thread. The locale setting is thread inheritable. This means that a child thread will have the same locale setting as its creator thread until it changes it explicitly.

Example of usage:

 NLS.setLocale(Locale.GERMAN);
 TransportText t = NLS.getBundleFor(TransportText.class);
 
  • Field Details

  • Constructor Details

    • NLS

      private NLS(Locale locale)
  • Method Details

    • setLocale

      public static void setLocale(Locale locale)
      Sets the locale for the calling thread.

      The getBundleFor(Class) method will honor this setting if it is supported by the provided resource bundle property files. Otherwise, it will use a fall back locale as described in the TranslationBundle

      Parameters:
      locale - the preferred locale
    • useJVMDefaultLocale

      public static void useJVMDefaultLocale()
      Sets the JVM default locale as the locale for the calling thread.

      Semantically this is equivalent to NLS.setLocale(Locale.getDefault()).

    • useJVMDefaultInternal

      private static NLS useJVMDefaultInternal()
    • getBundleFor

      public static <T extends TranslationBundle> T getBundleFor(Class<T> type)
      Returns an instance of the translation bundle of the required type. All public String fields of the bundle instance will get their values injected as described in the TranslationBundle.
      Parameters:
      type - required bundle type
      Returns:
      an instance of the required bundle type
      Throws:
      TranslationBundleLoadingException - see TranslationBundleLoadingException
      TranslationStringMissingException - see TranslationStringMissingException
    • clear

      public static void clear()
      Release resources held by NLS
      Since:
      5.8
    • get

      private <T extends TranslationBundle> T get(Class<T> type)