Pluf Framework

Pluf Framework Commit Details


Date:2009-01-12 14:26:45 (15 years 11 months ago)
Author:Loic d'Anterroches
Branch:develop, master
Commit:1ed1eeb958889ec0c9ea382401988a7e7950cdc1
Parents: 7a31ad2a7ceef876df8eb73e84c97925ef7a9e50
Message:Added a cache of the translation files.

Changes:

File differences

src/Pluf/Translation.php
141141
142142
143143
144
145
146
144147
145148
146149
......
241244
242245
243246
244
247
245248
246249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
247280
248281
249282
*/
public static function readPoFile($file)
{
if (false !== ($hash=self::getCachedFile($file))) {
return $hash;
}
// read .po file
$fc= file_get_contents($file);
// normalize newlines
$hash[$entry['msgid']]= $entry['msgstr'];
}
}
self::cacheFile($file, $hash);
return $hash;
}
/**
* Load optimized version of a language file if available.
*
* @return mixed false or array with value
*/
public static function getCachedFile($file)
{
$phpfile = Pluf::f('tmp_folder').'/Pluf_L10n-'.md5($file).'.phps';
if (file_exists($phpfile)
&& (filemtime($file) < filemtime($phpfile))) {
return include $phpfile;
}
return false;
}
/**
* Cache an optimized version of a language file.
*
* @param string File
* @param array Parsed hash
*/
public static function cacheFile($file, $hash)
{
$phpfile = Pluf::f('tmp_folder').'/Pluf_L10n-'.md5($file).'.phps';
file_put_contents($phpfile,
'<?php return '.var_export($hash, true).'; ?>',
LOCK_EX);
@chmod($phpfile, 0666);
}
}

Archive Download the corresponding diff file

Branches

Tags

Number of commits:
Page rendered in 0.06173s using 13 queries.