DESCR_ Locale

View: New views
2 Messages — Rating Filter:   Alert me  

DESCR_ Locale

by Jon Elofson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
A quick question. I am building a form element and was adding a
description to the element (a select). I added a DESC_FOO to the
locale file and noticed it didn't show up. Adding plain text worked
fine. I found the code in the form helper which builds the descr part
and see that if the desc is empty or starts with DESCR_ then the
method simply returns null. Obviously that is intentional, I am just
not sure why. Care to elaborate?  Looks like the descr doesn't get
automatic localization, so you just localize the text beforehand. Yes?

'descr'=>$this->locale('DESCR_FOO')

Argh. It's snowing :(

Jon

--
Sent from my mobile device
_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk

Re: DESCR_ Locale

by Paul M Jones-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Oct 8, 2009, at 10:22 , Jon Elofson wrote:

> Hello,
> A quick question. I am building a form element and was adding a
> description to the element (a select). I added a DESC_FOO to the
> locale file and noticed it didn't show up. Adding plain text worked
> fine. I found the code in the form helper which builds the descr part
> and see that if the desc is empty or starts with DESCR_ then the
> method simply returns null. Obviously that is intentional, I am just
> not sure why. Care to elaborate?

Sure.

First off, descriptions are generally not used a lot, and are a lot  
less standardized than labels.

Now, when you call locale(), if there's no string returned, the locale  
key itself is used as the translated string.  It is ugly and it stands  
out so that you can see you forgot to provide a translation.

Because descriptions are optional, *and* because they always get  
checked-for when building a form, means that you get a lot of  
"DESCR_FOO" in your output when you really just want it to be blank.  
Thus, we check to see if the description is "DESCR_*" (meaning no  
translation was found) and ignore it if so.

Also, because descriptions are very non-standard, they are allowed to  
contain HTML or JavaScript and are *not* escaped by default.

Kind of roundabout, I know.


> Looks like the descr doesn't get automatic localization, so you just  
> localize the text beforehand. Yes?
>
> 'descr'=>$this->locale('DESCR_FOO')

Hm, I don't recall why I don't call $this->_view->getText() on the  
DESCR_* value.  I'm betting that's an oversight on my part.  Would you  
care to file a bug on it in Trac for me, so I don't forget?


--

Paul M. Jones
http://paul-m-jones.com/




_______________________________________________
Solar-talk mailing list
Solar-talk@...
http://mailman-mail5.webfaction.com/listinfo/solar-talk