Interface DefaultCaptionProvider


public interface DefaultCaptionProvider
  • Method Details

    • forClassLoader

      static @NonNull DefaultCaptionProvider forClassLoader(@NonNull ClassLoader classLoader, @NonNull Function<@NonNull Locale,​@NonNull String> urlProvider)
      Returns a DefaultCaptionProvider that loads captions from a ClassLoader's resources. The resource urls are determined by applying the given function to a locale.
      Parameters:
      classLoader - the class loader to load caption resources from.
      urlProvider - the function to get an url from a locale.
      Returns:
      a caption provider using a function to determine resource urls.
    • forClassLoaderFormatString

      static @NonNull DefaultCaptionProvider forClassLoaderFormatString(@NonNull ClassLoader classLoader, @NonNull String toFormat)
      Returns a DefaultCaptionProvider that loads captions from a ClassLoader's resources. The resource urls are determined by replacing the first occurrence of %s in the string with Locale.toString().
      Parameters:
      classLoader - the class loader to load caption resources from.
      toFormat - a string that can be formatted to result in a valid resource url when calling String.format(toFormat, Locale#toString)
      Returns:
      a caption provider using string formatting to determine resource urls.
    • loadDefaults

      @Nullable Map<@NonNull String,​@NonNull String> loadDefaults(@NonNull Locale locale)
      Loads default translation values for a specific language and returns it as a map. If no default translation exists, null is returned. A returned map might be empty.
      Parameters:
      locale - the locale to load the values for.
      Returns:
      a map of default values for the given locale.