Open erik-zicht opened 4 years ago
@7ochem @patrick-zicht
Check https://github.com/lexik/LexikTranslationBundle, there is a Command that does this, this bundle seems not to be integrated with a cache-warmup.
edit: https://github.com/lexik/LexikTranslationBundle/blob/master/Translation/Loader/DatabaseLoader.php through this loader they run almost the same code as we do in Zicht\Bundle\MessagesBundle\Translation\Loader
Currently the
Zicht\Bundle\MessagesBundle\Translation\Loader
needs database access in thecache:clear
process to examine which translations are available to add to the overall catalogue for each locale. They will be merged with existing translations and somewhere later dumped to the cache-directory.This is bad practice, as it makes the applications stateful in a process that should be stateless. A cache-clear should be performed regardless of implementation details such as the database. If the filesystem it will be deployed on supports write-actions, this might be performed at a later stage.
Adding translations in cache-warmup is a sophisticated process traced back to several private methods in
Symfony\Bundle\FrameworkBundle\Translation\Translator
.Possible is a workaround such as:
catalogue.<locale>.*
from /var/cache/translationsOnly problem is a race-condition between normal requests filling the cache again and the execution of this new command.
Other solutions: