Interface DefaultCaptionProvider
public interface DefaultCaptionProvider
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull DefaultCaptionProvider
forClassLoader(@NonNull ClassLoader classLoader, @NonNull Function<@NonNull Locale,@NonNull String> urlProvider)
Returns a DefaultCaptionProvider that loads captions from aClassLoader
's resources.static @NonNull DefaultCaptionProvider
forClassLoaderFormatString(@NonNull ClassLoader classLoader, @NonNull String toFormat)
Returns a DefaultCaptionProvider that loads captions from aClassLoader
's resources.loadDefaults(@NonNull Locale locale)
Loads default translation values for a specific language and returns it as a map.
-
Method Details
-
forClassLoader
static @NonNull DefaultCaptionProvider forClassLoader(@NonNull ClassLoader classLoader, @NonNull Function<@NonNull Locale,@NonNull String> urlProvider)Returns a DefaultCaptionProvider that loads captions from aClassLoader
'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 aClassLoader
's resources. The resource urls are determined by replacing the first occurrence of%s
in the string withLocale.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 callingString.format(toFormat, Locale#toString)
- Returns:
- a caption provider using string formatting to determine resource urls.
-
loadDefaults
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.
-