RE: I18n/l10n

"Aapo Laakkonen" <[email protected]>
Newsgroups gmane.comp.web.maverick.general
Organization ProjectCast Oy
Message-ID <000001c381c1$0ae11420$51d14e3e@bungle>
> 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:

@title@=TITLE
@welcome.message@=HELLO
@error.message@=User {1} was not found in db.
@user.details@=Hi {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:

@title@=TITLE
@welcome.message@=HELLO
@error.message@=User $!{user.name} was not found in db.
@user.details@=Hi $!{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]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.