-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Add new translation files without clearing the cache #27600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi! I had a real-life case for this feature with php-translation/symfony-bundle. With @damienalexandre and @lyrixx, we opened an issue to explain our case here. |
Well, the handling of translation files is done in 2 steps, both with caching:
I think it could be possible to add a new resource in the message catalogue cache checking freshness based on the list of resources in the translator (but it might be hard if this list of resources is maintained by a different object. I don't remember how the architecture works exactly in 4.1 as this changed over time in Symfony) |
@welcoMattic your issue is different, as this is not about a debug mode, but about a prod mode. Your issue is related to the DI-level caching, because you tried to avoid clearing the container cache. |
There's something I don't get here. @javiereguiluz and @stof gave what I understand as conflicting sentences:
Who is right? |
@nicolas-grekas I can confirm that newly added translation files in Tested in 4.1.0 |
I'm not describind the supposed state. If you read my first comment, you will see that the second bullet point precisely describes where the invalidation is not done properly. |
This PR was squashed before being merged into the 4.3-dev branch (closes #28937). Discussion ---------- Improve Translator caching | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27600 | License | MIT | Doc PR | N/A 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). Commits ------- a524658 Improve Translator caching
Description
Don't require to clear cache when adding new translation files.
Example
If you add a new translation file, the app won't use it unless you clear the cache entirely. This is cumbersome and inconsistent with other parts of the framework.
Is there any tech constraint that prevents us from checking if there are new files in the
translations/
dir and load them automatically (indev
)?The text was updated successfully, but these errors were encountered: