Class Internationalization

java.lang.Object
megamek.common.internationalization.Internationalization

public class Internationalization extends Object
Class to handle internationalization (you will find online material on that looking for i18n) It makes use of some short names to make it easier to use since it is used in many places
  • Field Details

  • Constructor Details

    • Internationalization

      protected Internationalization(String defaultBundle)
  • Method Details

    • getInstance

      public static Internationalization getInstance()
    • getTextAt

      public static String getTextAt(String bundleName, String key)
      Get a localized string from a specific bundle
      Parameters:
      bundleName - the name of the bundle
      key - the key of the string
      Returns:
      the localized string
    • getText

      public static String getText(String key)
      Get a localized string from the default bundle
      Parameters:
      key - the key of the string
      Returns:
      the localized string
    • getFormattedText

      public static String getFormattedText(String key, Object... args)
      Get a formatted localized string from the default bundle
      Parameters:
      key - the key of the string
      args - the arguments to format the string
      Returns:
      the localized string
    • getFormattedTextAt

      public static String getFormattedTextAt(String bundleName, String key, Object... args)
      Get a formatted localized string from the default bundle
      Parameters:
      bundleName - the name of the bundle
      key - the key of the string
      args - the arguments to format the string
      Returns:
      the localized string
    • normalizeTextToASCII

      public static String normalizeTextToASCII(String text, boolean cache)
      Takes a string of Unicode text and attempts to convert it to an ASCII representation of that string. Characters such as ø and ö will be converted to o.
      Parameters:
      text - A String, such as Gún or Götterdämmerung
      cache - Set to try to cache the result. The memoization cache can grow indefinitely, so care should be taken to not fill the cache with strings that might never be referenced again. For example, strings typed by the user shouldn't be cached, but unit names should be.
      Returns:
      The normalized String, such as Gun or Gotterdammerung.
      The returned string is not guaranteed to be only ASCII. Normalization will fail if there's no direct mapping from a character to its ASCII equivalent.