Open sguter90 opened 1 year ago
Hey @sguter90, thanks for raising and proposing a workaround.
Is this a similar issue to what PR https://github.com/adamduncan/eleventy-plugin-i18n/pull/18 was looking to solve? (A little additional context there from the time)
Is it something that folks can handle via 11ty's built-in addWatchTarget
API? IMO it might make more sense to try to solve that on the framework side as opposed to here on the plugin side.
Hope that helps 👍
Hi @adamduncan , yes, #18 would provide a way to solve my problem 👍 I'm fetching translations from a repote API and write them to a data file with a parallel running process. Everytime the translation file changes a rebuild is triggered by eleventy.
As far as I know addWatchTarget also just triggers the build logic but not restarts the watch process where plugins are added. (which re-imports js dependencies)
Because you linked https://github.com/11ty/eleventy/issues/1312 I've checked if eleventy version v2.0.2-alpha.1
solves this issue.
But this doesn't seem to change anything regarding require statements. (or I'm missing something)
It would be very nice to detect changes in the translation files.
Via
translations
configuration you can only set an object containing translations. Every time a translation changes, the eleventy server needs to be restarted when usingwatch
.I worked around this issue by defining a
Proxy
:Eleventy detects the change by itself and reloads the page which then fetches translation for EVERY
i18n
filter call. This works for small setups as a very dirty workaround.So what I was thinking of was is adding a
eleventy.before
hook to the plugin which then resets the registered translations (or re-initalizes the filter) if one of the translations files changed (defined via a newtranslationFiles
property).Do you think that this makes sense?