bug #30921 [Translator] Warm up the translations cache in dev (tgalopin)

This PR was merged into the 3.4 branch.

Discussion
----------

[Translator] Warm up the translations cache in dev

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This PR fixes a bug in development when using the DataCollectorTranslator: because it's not implementing WarmableInterface, the translations cache is not built during cache:clear during development.

Commits
-------

a5f1afca15 [Translator] Warm up the translations cache in dev
This commit is contained in:
Fabien Potencier 2019-04-06 20:09:42 +02:00
commit 3e0b2354db

View File

@ -11,12 +11,13 @@
namespace Symfony\Component\Translation; namespace Symfony\Component\Translation;
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
use Symfony\Component\Translation\Exception\InvalidArgumentException; use Symfony\Component\Translation\Exception\InvalidArgumentException;
/** /**
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com> * @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
*/ */
class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInterface class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInterface, WarmableInterface
{ {
const MESSAGE_DEFINED = 0; const MESSAGE_DEFINED = 0;
const MESSAGE_MISSING = 1; const MESSAGE_MISSING = 1;
@ -87,6 +88,14 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
return $this->translator->getCatalogue($locale); return $this->translator->getCatalogue($locale);
} }
/**
* {@inheritdoc}
*/
public function warmUp($cacheDir)
{
return $this->translator->warmUp($cacheDir);
}
/** /**
* Gets the fallback locales. * Gets the fallback locales.
* *