I want to have language specific velocity template. Each one should be in its own template File (with an language “postfix” like the one used for normal resource files).
At the moment I am using:
String content = VelocityEngineUtils.mergeTemplateIntoString(this.velocityEngine,
“newPasswordRequestDoubleOpt_locale.getLanguage().vm”,
model);
But then I have to deal my own with problem like, fall back to an other language if there is no template for the current one….
So I am asking is there already some kind of build in functionality in Velocity that handles this complete language specific template stuff? Or is there a better way?
(use case: I use Velocity to generate the Email content, most of it is some text, only some “variables”.)
Well, I think you’re taking the wrong approach when you assume that your text is not a variable.
Velocity, like any other template is designed to focus structure, not content. So you text should be part of your variables. Doing so, you could benefit of the velocity tools, like the ResourceTool that allow you to deal with ResourceBundles that would contains your text.