feat: add help message #3

Merged
polpetta merged 13 commits from help into devel 2023-04-20 11:30:07 +02:00
Showing only changes of commit 8dd547404d - Show all commits

View File

@ -9,6 +9,14 @@ import org.apache.velocity.tools.ToolManager;
import org.apache.velocity.util.StringBuilderWriter;
// FIXME doc, tests
/**
* This class aims to generate localized messages or strings either merging Velocity templates or
* taking directly the keys from {@link java.util.ResourceBundle}
*
* @author Davide Polonio
* @since 1.0
*/
public class TemplateContentGenerator {
private final LocalizedMessageFactory localizedMessageFactory;
@ -18,6 +26,19 @@ public class TemplateContentGenerator {
this.localizedMessageFactory = localizedMessageFactory;
}
/**
* Merge a Velocity template located in the local Jar resource path with the given {@link Locale},
* provided as a {@link String}. A {@link Consumer} is provided in order to let the user customize
* the {@link VelocityContext} with additional variables. Localization strings will be directly
* taken via the use of {@link LocalizedTool} class.
*
* @param velocityContextConsumer a lambda function that allows for the customization of {@link
* VelocityContext} instance
* @param localeAsString a {@link Locale} formatted as a {@link String}. Note that {@link
* Locale#forLanguageTag(String)} will be used for the conversion
* @param templateName the path to the local Jar resource
* @return a {@link String} containing the localized message
*/
public String mergeTemplate(
Consumer<VelocityContext> velocityContextConsumer,
String localeAsString,