Include new translations by clearing cache and precompiling assets #901
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #856
Currently, we're relying on the
i18n-js
gem and utilizing it through the asset pipeline for our translations. When adding a new locale, these changes aren't being reflected on the front end. Only after changing any of the existingyml
files will the fingerprint for the assets be updated and trigger a refresh.After doing some digging, this is actually the intended design by Sprockets.
Relevant issue: #213 within i18n-js
Provided Workarounds: https://github.com/fnando/i18n-js/tree/v3#missing-translations-in-precompiled-files-after-adding-any-new-locale-file
For this PR, I went with the first option of calling rake tasks on the rails container after it's spun up. These commands clear the cache and force a precompile of all the assets. Because the cache has been cleared, it picks up all existing locales(old and new) and provides them to the front end. I've tested on both
offline
anddev
profiles with the following steps:bin/setup
docker compose --profile dev up
ordocker compose --profile offline up
localhost:3000
and confirm splash page with translationsconfig/locales
,cp -r en/ it/
then modify allyml
files within the new directory from theen
toit
keydocker compose
with ctrl+c and rerun the command from step 2localhost:3000
and new it translations will be presentWhile this won't "hot load" new translations, it will ensure anything new will be included at the start of the rails container.
Option 2 from the
i18n-js
docs is what we're already doing.Option 3 from the
i18n-js
docs might be an easier and better solution, but wanted to discuss on path forward.