RE: I18n/l10n
"Jaap van Hengstum" <[email protected]>
| Newsgroups | gmane.comp.web.maverick.general |
|---|---|
| Message-ID | <[email protected]> |
Again, correct me if I'm wrong :-) But what if there would not be just one message but instead one message (selected at runtime) out of a possible number of messages. The view would then have to either [1] select the localized message at runtime or [2] include every possible message at compiletime and display one of them based on some property returned at runtime. And [2] - if I realize correctly - is just like [1], it would still require some ResourceBundle-like functionality (which ofcourse could be implemented using Velocity macros). Anyway, it's not really a problem, just something I was thinking about since your "build-time" approach looks interesting enough to consider. -----Oorspronkelijk bericht----- Van: Aapo Laakkonen [mailto:[email protected]] Verzonden: Tuesday, September 23, 2003 12:54 PM Aan: [email protected] Onderwerp: RE: [Mav-user] I18n/l10n > 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] ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf [INVALID FOOTER]