i18n-node-2
i18n-node-2 copied to clipboard
Large HB project, seems to write to JSON file over and over even with no changes
I have a project set up with a watcher to regenerate templates on language file change - but the action of running the template generation sends the thing into a loop as it detects changes to the i18n json file and runs over and over again, even when there are no new keys added.
Is there a way to a) simply prevent updating of the json file? I'm happy adding my own keys or b) making the module only create a new json file on change?
I'm not sure what you mean. I think devMode is supposed to prevent writing files and might help you
I am using livereload to reload the pages I'm working on when they change. I'm using a watcher to generate HTML from HBS templates when those templates change I'm also using a watcher to generate HTML from HBS templates when the language file changes too
However, every time HBS generates pages, i18n-node-2 writes to the language file, even if I've not changed any text/added any keys
This leads to a loop whereby the two watchers are triggering each other.
For the time being I've added
dump: function () {
throw ('error');
}
into the options passed in on instantiation which forces it to throw an error before it tries to write to the file, this works but fills my debug log with error messages...
devMode would work but unfortunately it caches the JSON meaning the page doesn't get updates when I add keys to the JSON. Is there an option to disable the cache?
Hm, I'm not sure if there is a solution to this and I don't have a lot of time to investigate myself.
If you ever find a solution, don't hesitate to discuss / PR.
I can certainly create a PR with a "preventWrite" option or something - if you'd like me to I'll do this, just let me know your preferred name for this option...
disableWrite
seems nice !
Thank you for your help
Hello, I am also facing the same issue(language file being modified by library). Is it required that the language file should be even touched by the i18n-node-2 code? As far as I can understand, the language file should be a constant (non changing) until the user himself goes and modifies it and the i18n program should just read it and use it for translation and nothing else. So, technically, the file should not change at all by the library. If it sees any errors in the translation file, it should throw the error and stop its work. Please let me know if my understanding is not right.
Thanks.