Package org.ka2ddo.yaac.util
Class Localizer
java.lang.Object
org.ka2ddo.yaac.util.Localizer
This class wraps all the business logic for searching ResourceBundles for localized
text messages for display on the UI and in reports. This will be used to phase out
dependencies on the YAAC main class (where these methods were originally located)
from code packages that do not depend on being in the YAAC application.
- Author:
- Andrew Pavlin, KA2DDO
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Get the appropriate localized String corresponding to a ResourceBundle tag name in a specific ResourceBundle.static String
Get the appropriate localized String corresponding to a ResourceBundle tag name in a specific ResourceBundle.static ResourceBundle
Get the appropriate locale-specific message bundle for YAAC.static ResourceBundle
getMsgBundle
(String altBundleName) Get the appropriate locale-specific variant of some message bundle in one or more of the provided plugins.static String
getMsgNoException
(String tagName) Get the appropriate localized String corresponding to a ResourceBundle tag name in a specific ResourceBundle.static void
Update the ClassLoader hierarchy that will be used to look for ResourceBundle property files.
-
Constructor Details
-
Localizer
public Localizer()
-
-
Method Details
-
setContextClassLoader
Update the ClassLoader hierarchy that will be used to look for ResourceBundle property files. This should be called by any code that dynamically loads additional jar files into the Java virtual machine after the jar file this class comes from.- Parameters:
cl
- ClassLoader to be the most complete set available
-
getMsgBundle
Get the appropriate locale-specific message bundle for YAAC.- Returns:
- a ResourceBundle that is the most locale-specific possible for the runtime environment
-
getMsgBundle
Get the appropriate locale-specific variant of some message bundle in one or more of the provided plugins.- Parameters:
altBundleName
- String base name of the ResourceBundle to search for- Returns:
- a ResourceBundle that is the most locale-specific possible for the runtime environment
-
getMsg
Get the appropriate localized String corresponding to a ResourceBundle tag name in a specific ResourceBundle. If the tagName String contains a colon ':', this is the delimiter between the ResourceBundle name and the name of the resource within the bundle; otherwise, the entire tagName string is considered to be the name of the resource within the default bundle.- Parameters:
tagName
- String name to look up- Returns:
- localized String corresponding to the tag, or NoSuchResourceException if the if the tag cannot be found
- Throws:
MissingResourceException
- if the tag cannot be found
-
getMsgNoException
Get the appropriate localized String corresponding to a ResourceBundle tag name in a specific ResourceBundle. If the tagName String contains a colon ':', this is the delimiter between the ResourceBundle name and the name of the resource within the bundle; otherwise, the entire tagName string is considered to be the name of the resource within the default bundle.- Parameters:
tagName
- String name to look up- Returns:
- localized String corresponding to the tag, or null if the if the tag cannot be found
- Throws:
MissingResourceException
- if the ResourceBundle cannot be found
-
getMsg
Get the appropriate localized String corresponding to a ResourceBundle tag name in a specific ResourceBundle.- Parameters:
bundleBaseName
- String name of bundle containing the tagtagName
- String name to look up- Returns:
- localized String corresponding to the tag, or NoSuchResourceException if the if the tag cannot be found
- Throws:
MissingResourceException
- if the bundle or tag cannot be found
-