@@ -346,8 +346,9 @@ protected function initializeCatalogue($locale)
346
346
347
347
/**
348
348
* @param string $locale
349
+ * @param bool $forceRefresh
349
350
*/
350
- private function initializeCacheCatalogue ($ locale )
351
+ private function initializeCacheCatalogue ($ locale, $ forceRefresh = false )
351
352
{
352
353
if (isset ($ this ->catalogues [$ locale ])) {
353
354
return ;
@@ -361,7 +362,7 @@ private function initializeCacheCatalogue($locale)
361
362
362
363
$ this ->assertValidLocale ($ locale );
363
364
$ cache = new ConfigCache ($ this ->cacheDir .'/catalogue. ' .$ locale .'.php ' , $ this ->debug );
364
- if (!$ cache ->isFresh ()) {
365
+ if ($ forceRefresh || !$ cache ->isFresh ()) {
365
366
$ this ->initializeCatalogue ($ locale );
366
367
367
368
$ fallbackContent = '' ;
@@ -392,13 +393,15 @@ private function initializeCacheCatalogue($locale)
392
393
393
394
use Symfony\Component\Translation\MessageCatalogue;
394
395
396
+ \$resourcesHash = '%s';
395
397
\$catalogue = new MessageCatalogue('%s', %s);
396
398
397
399
%s
398
- return \$catalogue;
400
+ return array( \$catalogue, \$ resourcesHash) ;
399
401
400
402
EOF
401
403
,
404
+ $ this ->getResourcesHash ($ locale ),
402
405
$ locale ,
403
406
var_export ($ this ->catalogues [$ locale ]->all (), true ),
404
407
$ fallbackContent
@@ -409,7 +412,22 @@ private function initializeCacheCatalogue($locale)
409
412
return ;
410
413
}
411
414
412
- $ this ->catalogues [$ locale ] = include $ cache ;
415
+ list ($ catalogue , $ resourcesHash ) = include $ cache ;
416
+
417
+ if ($ this ->debug && ($ resourcesHash !== $ this ->getResourcesHash ($ locale ))) {
418
+ return $ this ->initializeCacheCatalogue ($ locale , true );
419
+ }
420
+
421
+ $ this ->catalogues [$ locale ] = $ catalogue ;
422
+ }
423
+
424
+ private function getResourcesHash ($ locale )
425
+ {
426
+ if (!isset ($ this ->resources [$ locale ])) {
427
+ return '' ;
428
+ }
429
+
430
+ return sha1 (serialize ($ this ->resources [$ locale ]));
413
431
}
414
432
415
433
private function doLoadCatalogue ($ locale )
0 commit comments