On 10/23/07, Peter Karman <[EMAIL PROTECTED]> wrote:
>> I keep the labels in the html templates.  I started using YAML files
>> to define the fields and labels, but then I ended up with more places
>> to define things than I felt was reasonable.
>
> Yes, that (labels in HTML) is what I do currently as well.

OTOH, the server often needs the labels in order to construct good
error messages.  An alternative is to pass error codes to the
templates, but IME that tends to result in templates with a lot of
code dedicated to figuring out which of several dozen error messages
should be displayed based on the error code passed.

But just passing a code is rarely sufficient, since good error
messages will have more request-specific information in them (e.g.,
"Could not delete the 'Foo' group because it still has 9 members.") so
an error object or structure of some kind is required.

That's essentially what happens under the covers when using RHTMLO's
localization system (the API is still not public or documented, sorry,
but the code is on CPAN if you're interested).  Each field is assigned
a label id rather than an actual text label, and errors are indicated
with a combination of a message id and the parameters to be inserted
into them.  What's returned from $field->error is actually an object
that knows how to stringify itself based on the error id, parameters,
and current locale.  All the actual Perl code deals only with message
ids, never strings, and all the templates do is stringify the objects
they're passed.

So, in the end, all the actual message text ends up not in the Perl
code or the templates, but in the big localized strings file or
whatever you're using for managing your localized messages.

-John

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to