Class ResourceBundles

java.lang.Object
com.xpdustry.distributor.api.translation.ResourceBundles

public final class ResourceBundles extends Object
Utilities for loading resource bundles.
  • Method Details

    • fromFile

      public static ResourceBundle fromFile(Locale locale, Path file)
      Loads a resource bundle from a file.
      Parameters:
      locale - the locale of the resource bundle
      file - the path to the file
      Returns:
      the created resource bundle
    • fromClasspathDirectory

      public static List<ResourceBundle> fromClasspathDirectory(Class<?> caller, String directory, String name)
      Loads resource bundles from a directory in the classpath.
      Parameters:
      caller - the class of the caller
      directory - the path to the directory
      name - the name of the bundle
      Returns:
      the loaded resource bundles
    • fromDirectory

      public static List<ResourceBundle> fromDirectory(Path directory, String name)
      Loads resource bundles from a directory.
      Parameters:
      directory - the path to the directory
      name - the name of the bundle
      Returns:
      the loaded resource bundles
    • fromZipDirectory

      public static List<ResourceBundle> fromZipDirectory(Path zip, String directory, String name)
      Loads resource bundles from a zip file.
      Parameters:
      zip - the path to the zip file
      directory - the path to the directory
      name - the name of the bundle
      Returns:
      the loaded resource bundles
    • getTextTranslation

      public static Translation getTextTranslation(ResourceBundle bundle, String key)
      Returns a text translation for the given key. Meant to be used with BundleTranslationSource.registerAll(ResourceBundle, BiFunction).
      Parameters:
      bundle - the resource bundle
      key - the key of the translation
      Returns:
      the text translation
    • getMessageFormatTranslation

      public static Translation getMessageFormatTranslation(ResourceBundle bundle, String key)
      Returns a message format translation for the given key. Meant to be used with BundleTranslationSource.registerAll(ResourceBundle, BiFunction).
      Parameters:
      bundle - the resource bundle
      key - the key of the translation
      Returns:
      the message format translation