protected function compilePhpCache(Translator $translator, array &$availableCatalogues, $locale)
{
$fallbackContent = '';
$current = new Code\PhpLiteral('');
foreach ($this->fallbackResolver->compute($translator, $locale) as $fallback) {
$fallbackSuffix = new Code\PhpLiteral(ucfirst(preg_replace('~[^a-z0-9_]~i', '_', $fallback)));
$fallbackContent .= Code\Helpers::format(<<<EOF
\$catalogue? = new MessageCatalogue(?, ?);
\$catalogue?->addFallbackCatalogue(\$catalogue?);
EOF
, $fallbackSuffix, $fallback, $availableCatalogues[$fallback]->all(), $current, $fallbackSuffix);
$current = $fallbackSuffix;
}
$content = Code\Helpers::format(<<<EOF
use Kdyby\\Translation\\MessageCatalogue;
\$catalogue = new MessageCatalogue(?, ?);
?
return \$catalogue;
EOF
, $locale, $availableCatalogues[$locale]->all(), new Code\PhpLiteral($fallbackContent));
return '<?php' . "\n\n" . $content;
}