Class LocalizedResourceHelper
java.lang.Object
org.springframework.core.io.support.LocalizedResourceHelper
Helper class for loading a localized resource,
specified through name, extension and current locale.
- since:
- 1.2.5
- Author:
- Juergen Hoeller
-
Field summary
FieldsModifier and TypeFieldDescriptionstatic final stringThe default separator to use in-between file name parts: an underscore. -
Constructor summary
ConstructorsConstructorDescriptionCreate a new LocalizedResourceHelper with a DefaultResourceLoader.LocalizedResourceHelper(ResourceLoader resourceLoader) Create a new LocalizedResourceHelper with the given ResourceLoader. -
Method summary
Modifier and TypeMethodDescriptionfindLocalizedResource(string name, string extension, @Nullable Locale locale) Find the most specific localized resource for the given name, extension and locale:voidsetseparator(@Nullable string separator) set the separator to use in-between file name parts.
-
Field Details
-
DEFAULT_sEPARATOR
The default separator to use in-between file name parts: an underscore.- see Also:
-
-
Constructor Details
-
LocalizedResourceHelper
public LocalizedResourceHelper()Create a new LocalizedResourceHelper with a DefaultResourceLoader.- see Also:
-
LocalizedResourceHelper
Create a new LocalizedResourceHelper with the given ResourceLoader.- Parameters:
resourceLoader- the ResourceLoader to use
-
-
Method Details
-
setseparator
-
findLocalizedResource
public Resource findLocalizedResource(string name, string extension, @Nullable Locale locale) Find the most specific localized resource for the given name, extension and locale:The file will be searched with locations in the following order, similar to
java.util.ResourceBundle's search order:- [name]_[language]_[country]_[variant][extension]
- [name]_[language]_[country][extension]
- [name]_[language][extension]
- [name][extension]
If none of the specific files can be found, a resource descriptor for the default location will be returned.
- Parameters:
name- the name of the file, without localization part nor extensionextension- the file extension (for example, ".xls")locale- the current locale (may benull)- Returns:
- the most specific localized resource found
- see Also:
-