Solar_Locale and named placeholders (was Re: [Solar-talk] Pager
helper changes)
Paul M Jones
pmjones at ciaweb.net
Mon Jul 2 11:45:20 CDT 2007
On Jul 2, 2007, at 11:39 AM, Rodrigo Moraes wrote:
> 2007/7/2, Paul M Jones:
>> Normally I don't like str_replace(), because if you have ":page" and
>> ":pages", the ":page" part of ":pages" gets matched and replaced
>> (leaving you with just the "s").
>
> Ah, indeed. I was sure to be missing something. :)
>
>> However, if we change the syntax a bit to "{:page}" then we can use
>> only str_replace() and a foreach() in Solar_Locale::_trans().
>> There's no preg*() call, and we don't have the mismatch problem
>> because the braces delimit the placeholder.
> [...]
>> Surely not as fast as vsprintf(), but I think it suits our purposes
>> (clarity and order-independence) -- especially since I don't see us
>> using lots of named replacements in any given locale string, or lots
>> of locale strings that need replacements.
>
> Yes, right. Performance was just something I thought of; indeed
> locales with replacements are not so common and, anyway, since
> vsprintf placeholders would still be available, I think everybody
> would be happy. :)
>
> +1
I'm glad to hear it passes the sanity test. :-)
I don't say this enough, but I really depend on (you guys taking the
time to work this stuff out and keep me in line. Thank you so
much. :-)
--
Paul M. Jones <http://paul-m-jones.com>
Solar: Simple Object Library and Application Repository
for PHP5. <http://solarphp.com>
Join the Solar community wiki! <http://solarphp.org>
Savant: The simple, elegant, and powerful solution for
templates in PHP. <http://phpsavant.com>
More information about the Solar-talk
mailing list