Solar_Locale and named placeholders (was Re: [Solar-talk] Pager helper changes)

Rodrigo Moraes rodrigo.moraes at gmail.com
Mon Jul 2 11:39:21 CDT 2007


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

-- rodrigo


More information about the Solar-talk mailing list