[Solar-talk] locale strings + replacements
Paul M Jones
pmjones at ciaweb.net
Tue Nov 28 18:21:43 PST 2006
My opinion on this is: if you need sprintf() formatting, you can keep
the format string as the locale string, then call sprintf() from the
view (instead of it being used in the locale() method when it's not
always needed). For example, say your locale key/value pair is this:
'TEXT_FOO' => 'The %2$s contains %1$d monkeys.'
Then in your view, you can do this:
echo sprintf(
$this->getText('TEXT_FOO'),
7,
'house'
);
Then you get the benefits of sprintf() when you need them, and the
benefits of not using sprintf() when you don't.
Have I missed anything here?
--
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