Class MCRLocaleResource
java.lang.Object
org.mycore.frontend.jersey.resources.MCRLocaleResource
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
init()
language()
Returns the current language in ISO 639 (two character) format.Returns all available languages of the application.translateJSON
(String lang, String key) Translates a set of keys to the given language.Translates a set of keys to the current language.translateText
(String lang, String key) Translates a single key to the given language.Translates a single key to the current language.
-
Constructor Details
-
MCRLocaleResource
public MCRLocaleResource()
-
-
Method Details
-
init
@PostConstruct public void init() -
language
Returns the current language in ISO 639 (two character) format.- Returns:
- current language as plain text
-
languages
Returns all available languages of the application. The codes are in ISO 639 (two character) format.- Returns:
- json array of all languages available
-
translateJSON
@GET @Produces("application/json;charset=utf-8") @Path("translate/{lang}/{key: .*\\*}") public String translateJSON(@PathParam("lang") String lang, @PathParam("key") String key) Translates a set of keys to the given language.- Parameters:
lang
- desired languagekey
- message key ending with an asterisk (e.g. component.classeditor.*)- Returns:
- json object containing all keys and their corresponding translation
-
translateJSONDefault
@GET @Produces("application/json;charset=utf-8") @Path("translate/{key: .*\\*}") public String translateJSONDefault(@PathParam("key") String key) Translates a set of keys to the current language.- Parameters:
key
- message key ending with an asterisk (e.g. component.classeditor.*)- Returns:
- json object containing all keys and their corresponding translation in current language
-
translateText
@GET @Produces("text/plain") @Path("translate/{lang}/{key: [^\\*]+}") public String translateText(@PathParam("lang") String lang, @PathParam("key") String key) Translates a single key to the given language.- Parameters:
lang
- desired languagekey
- the key to translate (e.g. component.classeditor.save.successful)- Returns:
- translated plain text
-
translateTextDefault
@GET @Produces("text/plain") @Path("translate/{key: [^\\*]+}") public String translateTextDefault(@PathParam("key") String key) Translates a single key to the current language.- Parameters:
key
- the key to translate (e.g. component.classeditor.save.successful)- Returns:
- translated plain text
-