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

When in Dev Mode JSON is overwritten when accidentally invalidating the JSON language file. #124

Open
Netgator opened this issue Feb 21, 2019 · 0 comments

Comments

@Netgator
Copy link

Related to Issue #39 which has been closed.

I noticed that in sails this is a NON-ISSUE however when implementing i18n-2 in my own class and executing it outside of sails this is STILL an issue.

The Issue: I have a fairly large en.js file with many of the strings "KEYED" to English sentences. For example: "TEST": "This is a Test message for %s"
I was manually adding my KEY/sentence pairs to the file while testing a custom class outside of sails. I inadvertently left off a comma on one of the pairs and the next time I started my "test" (because I was outside of sails in DEV mode with an "invalid" JSON file) the i18n-2 package OVERWROTE the ENTIRE en.js file because of ONE missing comma!

It would be nice if the package just automatically prevented an overwrite even in DEV mode if the following are ALL TRUE: 1.) language file exists 2.) file IS NOT EMPTY 3.) file is INVALID JSON. If this doesn't make sense then a second option would be to add a configuration option to the "setup" config that while in DEV mode I can say that YES I want the strings to be automatically written to the file HOWEVER if the JSON is invalid to error and stop completely.

Like:
let i18n = new(require('i18n-2'))({
locales: ['en'],
error_invalid_language: true
});

Netgator added a commit to Netgator/i18n-node-2 that referenced this issue Feb 21, 2019
…le in DEV mode.

If JSON file exists and in DEV mode but the locale is undefined - HALTS ALL execution with an expection to prevent the files from being overwritten.
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

1 participant