Class LocalizedStringLoader

java.lang.Object
com.lokalized.LocalizedStringLoader

@ThreadSafe public final class LocalizedStringLoader extends Object
Utility methods for loading localized strings files.
Author:
Mark Allen
  • Method Details

    • loadFromClasspath

      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:

      • en
      • en.json
      • es-MX
      • es-MX.json
      • nan-Hant-TW

      Like any classpath reference, packages are separated using the / character.

      Example package names:

      • strings
      • com/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

      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:

      • en
      • en.json
      • es-MX
      • es-MX.json
      • nan-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