Description
When using the Translation component in debug mode, I noticed that the .meta files being generated do not include references to fallback locale files, even though the actual cache file contains messages from the fallback locales. This is an issue because any changes made to one of the fallback locale files will not take effect unless the cache is deleted.
Interestingly, in the example, when instantiating the translator with the locale of "fr" instead of "fr_FR", the .meta file correctly contains references to the main locale and fallback locales.
example.php:
<?php declare(strict_types = 1);
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\Loader\PhpFileLoader;
// require symfony/translation and symfony/config in composer.json
require "vendor/autoload.php";
$path = pathinfo(__FILE__);
$frResourceFile = "{$path["filename"]}.trans.fr.php";
$enResourceFile = "{$path["filename"]}.trans.en.php";
file_put_contents($frResourceFile, '<?php return ["greeting" => "Salut!"];');
file_put_contents($enResourceFile, '<?php return ["greeting" => "Hello!"];');
$trans = new Translator("fr_FR", null, ".", true);
$trans->setFallbackLocales(["en"]);
$trans->addLoader("php", new PhpFileLoader());
$trans->addResource("php", $frResourceFile, "fr");
$trans->addResource("php", $enResourceFile, "en");
echo $trans->trans("greeting");
Expected catalogue.fr.xxxxx.php.meta to contain:
a:2:{i:0;C:46:"Symfony\Component\Config\Resource\FileResource":76:{s:68:
"/path/to/example.trans.fr.php"
;}i:1;C:46:"Symfony\Component\Config\Resource\FileResource":76:{s:68:
"/path/to/example.trans.en.php";}}
But instead received:
a:1:{i:0;C:46:"Symfony\Component\Config\Resource\FileResource":76:{s:68:
"/path/to/example.trans.fr.php";}}
As a temporary workaround for anyone else having this issue, you can pass null to the third parameter while developing and it won't create cache files, avoiding the issue:
$debug = (getenv("DEBUG_MODE") === "true");
$cacheDir = $debug ? null : "/path/to/cache";
$trans = new Translator("fr_FR", null, $cacheDir, $debug);