> At the moment, I use a combination of (1) and (2).
> A disadvantage of (4) - if I see it correctly -
> is that I create messages at runtime (f.e. validation
> error messages) and it would be more complicated in
> the view if I had to create them at compiletime.

Yes, but as I see those validation messages come from resource bundles?

So that makes me wondering how would it make it more complicated.

Here is example what I'm thinking (in velocity):

<html>
<head><title>@title@</title></head>
<body>
<h1>@welcome.message@</h1>
<p>
#if (${errors.message})
        #err("@error.message@", ["$!{user.name}"])
#else
        #msg("@user.details@"), ["$!{user.name}", "$!{user.age}"]);
#end
</p>
</body>
</html>

And here is the resource bundle:

@[EMAIL PROTECTED]
@[EMAIL PROTECTED]
@[EMAIL PROTECTED] {1} was not found in db.
@[EMAIL PROTECTED] {1}, it seems that your are getting older, {2} years
behind and counting.

#err and #msg are velocity macros that do parameter replaces. As you
see, the static messages are translated build-time and parameter
replacing happens in runtime.

Another possibility would be to write #evel macro and then everything
looks like this:

<html>
<head><title>@title@</title></head>
<body>
<h1>@welcome.message@</h1>
<p>
#if (${errors.message})
        #eval("@error.message@")
#else
        #eval("@user.details@");
#end
</p>
</body>
</html>

And resource bundle looks like this:

@[EMAIL PROTECTED]
@[EMAIL PROTECTED]
@[EMAIL PROTECTED] $!{user.name} was not found in db.
@[EMAIL PROTECTED] $!{user.name}, it seems that your are getting older,
$!{user.age} years behind and counting.


What do you think?



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
[INVALID FOOTER]

Reply via email to