Class ResourceBundles
java.lang.Object
com.xpdustry.distributor.api.translation.ResourceBundles
Utilities for loading resource bundles.
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<ResourceBundle>fromClasspathDirectory(Class<?> caller, String directory, String name) Loads resource bundles from a directory in the classpath.static List<ResourceBundle>fromDirectory(Path directory, String name) Loads resource bundles from a directory.static ResourceBundleLoads a resource bundle from a file.static List<ResourceBundle>fromZipDirectory(Path zip, String directory, String name) Loads resource bundles from a zip file.static TranslationgetMessageFormatTranslation(ResourceBundle bundle, String key) Returns a message format translation for the given key.static TranslationgetTextTranslation(ResourceBundle bundle, String key) Returns a text translation for the given key.
-
Method Details
-
fromFile
Loads a resource bundle from a file.- Parameters:
locale- the locale of the resource bundlefile- 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 callerdirectory- the path to the directoryname- the name of the bundle- Returns:
- the loaded resource bundles
-
fromDirectory
Loads resource bundles from a directory.- Parameters:
directory- the path to the directoryname- the name of the bundle- Returns:
- the loaded resource bundles
-
fromZipDirectory
Loads resource bundles from a zip file.- Parameters:
zip- the path to the zip filedirectory- the path to the directoryname- the name of the bundle- Returns:
- the loaded resource bundles
-
getTextTranslation
Returns a text translation for the given key. Meant to be used withBundleTranslationSource.registerAll(ResourceBundle, BiFunction).- Parameters:
bundle- the resource bundlekey- the key of the translation- Returns:
- the text translation
-
getMessageFormatTranslation
Returns a message format translation for the given key. Meant to be used withBundleTranslationSource.registerAll(ResourceBundle, BiFunction).- Parameters:
bundle- the resource bundlekey- the key of the translation- Returns:
- the message format translation
-