[Solar-talk] Solar_Locale fetch method
Paul M Jones
pmjones at ciaweb.net
Mon May 28 11:19:35 PDT 2007
Hi Pierre,
On Apr 29, 2007, at 12:30 PM, Pierre Oztel wrote:
> When calling Solar_Base::fetch('key') multiple times, Solar_Locale
> is happily reloading locales files array.
>
> For example:
>
> for($i = o; $i < 100 ; $i++) {
>
> $this->locale('ERR_CLASS_NOT_EXISTS');
> }
>
> I fixed that by switching the Solar_Locale::$trans property to static.
>
> It resulted in on total call on the Solar_Locale::_load(method)
I don't see the same behavior here; are you using Solar 0.27.1 or the
SVN release, or are you using an earlier release?
I tested this way:
1. In Solar_Locale::_load(), I added `echo "Loading for $class...
\n";` at the very top of the method. That way it only echoes when
trying to load a locale file.
2. Then I ran this script:
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', true);
set_include_path('/Users/pmjones/pear/php');
require_once 'Solar.php';
Solar::start(false);
class Example extends Solar_Base {}
$example = Solar::factory('Example');
for($i = 0; $i < 10 ; $i++) {
echo $example->locale('NO_SUCH_KEY') . "\n";
}
echo "Done!\n";
The output looks like this (and it looks correct to me).
Loading for Example...
Loading for Solar_Base...
Loading for Solar...
NO_SUCH_KEY
NO_SUCH_KEY
NO_SUCH_KEY
NO_SUCH_KEY
NO_SUCH_KEY
NO_SUCH_KEY
NO_SUCH_KEY
NO_SUCH_KEY
NO_SUCH_KEY
NO_SUCH_KEY
Done!
So I don't see where it's re-loading the locale translations. Have I
missed what you were getting at?
--
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