public class LanguageResourceService extends Object
Constructor and Description |
---|
LanguageResourceService() |
Modifier and Type | Method and Description |
---|---|
void |
addLanguageResource(String key,
Resource resource)
Adds or overlays the given language resource, which need not exist in
the ServletContext.
|
void |
addLanguageResources(javax.servlet.ServletContext context)
Adds or overlays all languages defined within the /translations
directory of the given ServletContext.
|
String |
getLanguageKey(String path)
Derives a language key from the filename within the given path, if
possible.
|
Set<String> |
getLanguageKeys()
Returns a set of all unique language keys currently associated with
language resources stored in this service.
|
Map<String,String> |
getLanguageNames()
Returns a mapping of all language keys to their corresponding human-
readable language names.
|
Map<String,Resource> |
getLanguageResources()
Returns a map of all languages currently associated with this service,
where the key of each map entry is the language key.
|
public String getLanguageKey(String path)
path
- The path containing the filename to derive the language key from.public void addLanguageResource(String key, Resource resource)
key
- The language key of the resource being added. Language keys are
pairs consisting of a language code followed by an underscore and
country code, such as "en_US".resource
- The language resource to add. This resource must have the mimetype
"application/json".public void addLanguageResources(javax.servlet.ServletContext context)
context
- The ServletContext from which language files should be loaded.public Set<String> getLanguageKeys()
public Map<String,Resource> getLanguageResources()
public Map<String,String> getLanguageNames()
Copyright © 2017. All rights reserved.