Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Improve Translator caching #28937
Add DirectoryResources to MessageCatalogues when loaded.
So that when a file is added to one of the directories the cache for all MessageCatalogues will be invalidated.
All directories must be added to all MessageCatalogues because we can't predict for which locale files will be added to each individual directory.
Also, now that the translator keeps track of its own directories for caching the container no longer needs to it. This means that when a translation changes or is added the container no longer needs to be fully rebuilt, saving a considerable amount of time (compilation time went down from ~4 seconds to ~1 second on each translation change/add in our project).
referenced this pull request
Oct 20, 2018
@nicolas-grekas I've rebased onto master and stopped using
This prevents a full container rebuild if any of the translation directories it was tracking but did not exist is created - it will only rebuild the Catalogue in that case, which is much faster.
I've also added some tests.
Could you check again please?
The list of files being loaded is still built by the container. So AFAICT, this change does not allow removing the resources at the container-level (we would still need to build the new list).
This change is already removing the resources from the container, and everything works fine without the container knowing where translations files reside. Why would it need to know about those?
The only reason I can think of is if I add another translations path to the framework, but then the resource where I define that is not fresh anymore, so the container would be rebuilt, and the change would cascade to the catalogues.