Skip to content
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

Large HB project, seems to write to JSON file over and over even with no changes #118

Open
scottlet opened this issue Feb 16, 2018 · 6 comments

Comments

@scottlet
Copy link

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?

@gjuchault
Copy link
Collaborator

I'm not sure what you mean. I think devMode is supposed to prevent writing files and might help you

@scottlet
Copy link
Author

scottlet commented Feb 20, 2018

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?

@gjuchault
Copy link
Collaborator

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.

@scottlet
Copy link
Author

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...

@gjuchault
Copy link
Collaborator

disableWrite seems nice !
Thank you for your help

@bgth
Copy link

bgth commented Jun 15, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants