public class LocalizedResourceHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_SEPARATOR
The default separator to use in-between file name parts: an underscore.
|
private ResourceLoader |
resourceLoader |
private java.lang.String |
separator |
Constructor and Description |
---|
LocalizedResourceHelper()
Create a new LocalizedResourceHelper with a DefaultResourceLoader.
|
LocalizedResourceHelper(ResourceLoader resourceLoader)
Create a new LocalizedResourceHelper with the given ResourceLoader.
|
Modifier and Type | Method and Description |
---|---|
Resource |
findLocalizedResource(java.lang.String name,
java.lang.String extension,
java.util.Locale locale)
Find the most specific localized resource for the given name,
extension and locale:
|
void |
setSeparator(java.lang.String separator)
Set the separator to use in-between file name parts.
|
public static final java.lang.String DEFAULT_SEPARATOR
private final ResourceLoader resourceLoader
private java.lang.String separator
public LocalizedResourceHelper()
DefaultResourceLoader
public LocalizedResourceHelper(ResourceLoader resourceLoader)
resourceLoader
- the ResourceLoader to usepublic void setSeparator(@Nullable java.lang.String separator)
public Resource findLocalizedResource(java.lang.String name, java.lang.String extension, @Nullable java.util.Locale locale)
The file will be searched with locations in the following order,
similar to java.util.ResourceBundle
's search order:
If none of the specific files can be found, a resource descriptor for the default location will be returned.
name
- the name of the file, without localization part nor extensionextension
- the file extension (e.g. ".xls")locale
- the current locale (may be null
)ResourceBundle