You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
});
The text was updated successfully, but these errors were encountered:
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.
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
});
The text was updated successfully, but these errors were encountered: