[Solar-talk] locale strings + replacements

Rodrigo Moraes rodrigo.moraes at gmail.com
Thu Nov 16 15:33:52 PST 2006


On 11/16/06, Antti Holvikari wrote:
> I wont :-)

Thank you. This was kind.

> Yep, my idea was *exactly* or very close to that. I can't remember why
> I didn't propose this feature. I had some ideas on howto hand those
> "replacements" to the Solar_Sql_Table validation rules. One could be
> to be able to use array for the locale string if you wanted the
> placeholders to be replaced like so:
>
> ...
> 'valid' => array('rangeLenght', array('This value should be %d-%d
> characters long', 4, 10), 4, 10),
> ...

Ah yes. I forgot that it could also improve the validation messages.
And this is a reason to implement the functionality in
Solar::locale(), not only in view helpers.

I only think it should use the (ugly) syntax that allows unordered
placeholders inside the string., e.g. 'This value should be %1$d-%2$d
characters long'. For some languages this is good and, although this
is a bad example to defend this, it allows you to re-create the phrase
using placeholders in any order - they will be correctly replaced.

> We would get rid of i.e VALID_RANGELENGTH's not so good feedback "This
> value is too short or too long" to something like "This value should
> be 4-10 characters long". I remember thinking this that it might be
> too complicated to implement everywhere so I guess that's why I
> dropped the idea.   Nevertheless, this is something worth reviewing.

Well, it wouldn't break existing code, so there is no need to
implement it everywhere - not in a hurry. It just opens the door for
better messages and improved locales. And puts Solar ahead in i18n
functionalities. :-)

rodrigo

---------------------------------------------------------------------
Solar has now a Community Wiki: solarphp.org
---------------------------------------------------------------------
Join the #solarphp IRC channel on freenode.org
---------------------------------------------------------------------


More information about the solar-talk mailing list