Fixes issue #124 JSON is overwritten if unable to parse the file in DEV#125
Fixes issue #124 JSON is overwritten if unable to parse the file in DEV#125Netgator wants to merge 13 commits intojeresig:masterfrom
Conversation
…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.
|
|
||
| locale = this.defaultLocale; | ||
|
|
||
| if ((this.devMode) && (fs.existsSync(this.locateFile(locale)))) { |
There was a problem hiding this comment.
Why would this condition would match if the defaultLocale have parsing errors ?
There was a problem hiding this comment.
I think you want this to be over line 331
There was a problem hiding this comment.
This code matches (and throws an error) when json is present BUT is (for example) missing one comma... You can test by creating a file with two comments and then remove the comma from the en.json file. Without this code the file is rewritten when a parse error occurs which potentially erases thousands of lines due to a missing comma :-)
This code prevents a json file from being overwritten when it has content but can not be parsed correctly.
There was a problem hiding this comment.
Don't think we want the extra line because the problem would occur in ANY language not just the default language...
updated code to make it compatiable with most current air-bnb /QSS eslint rules. researched syncronis functions and realized that this only applies in DEFV mode - otherwise the files are cached on startup.
Explicit language parameter in query, domain or session must have precedence over "preferred" language present in the "Accept-Language" header.
Optionally pass custom query string parameter
update to make the default extension to be .json rather than .js
Update i18n.js tonprevent crashes
Dependency updates for NODE 22
Fixes issue #124 JSON is overwritten if unable to parse the file in DEV mode.
If locale JSON file exists AND package is in DEV mode AND the locale is undefined (unreadable) - This HALTS ALL execution by throwing an exception which prevents the locale file(s) from being overwritten inadvertently. The issue is when the JSON is invalid (even just missing a comma) the file is automatically overwritten which can cause developers to loose most existing lines from the file and no way to recover...