Class LocalizedStringLoader
java.lang.Object
com.lokalized.LocalizedStringLoader
Utility methods for loading localized strings files.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionloadFromClasspath(@NonNull String classpathPackage) Loads all localized string files present in the specified package on the classpath.loadFromFilesystem(@NonNull Path directory) Loads all localized string files present in the specified directory.
-
Method Details
-
loadFromClasspath
public static @NonNull Map<@NonNull Locale, @NonNull Set<@NonNull LocalizedString>> loadFromClasspath(@NonNull String classpathPackage) Loads all localized string files present in the specified package on the classpath.Filenames must correspond to the IETF BCP 47 language tag format, optionally suffixed with
.json.Example filenames:
enen.jsones-MXes-MX.jsonnan-Hant-TW
Like any classpath reference, packages are separated using the
/character.Example package names:
stringscom/lokalized/strings
Note: this implementation only scans the specified package, it does not descend into child packages.
- Parameters:
classpathPackage- location of a package on the classpath, not null- Returns:
- per-locale sets of localized strings, not null
- Throws:
LocalizedStringLoadingException- if an error occurs while loading localized string files
-
loadFromFilesystem
public static @NonNull Map<@NonNull Locale, @NonNull Set<@NonNull LocalizedString>> loadFromFilesystem(@NonNull Path directory) Loads all localized string files present in the specified directory.Filenames must correspond to the IETF BCP 47 language tag format, optionally suffixed with
.json.Example filenames:
enen.jsones-MXes-MX.jsonnan-Hant-TW
Note: this implementation only scans the specified directory, it does not descend into child directories.
- Parameters:
directory- directory in which to search for localized string files, not null- Returns:
- per-locale sets of localized strings, not null
- Throws:
LocalizedStringLoadingException- if an error occurs while loading localized string files
-