Improve auto string addition to produce better diffs and ease merging.
## Issue - The diff for new strings are polluted by the need to add a comma to the previous entry. - Having to re-add the newline at the end of file before commiting is a repetitive pain. ## Caveats to this approach - When manually adding strings, developers need to put it above the `--end--` entry. Hopefully it is obvious without having to put verbose comments like "^--- add new string before this line ---^" - Translators will surely ask how to translate "--end--".
This commit is contained in:
parent
5c6e2e96fb
commit
7feb123a45
2 changed files with 7 additions and 2 deletions
|
@ -1273,5 +1273,6 @@
|
||||||
"Unlink YouTube Channel": "Unlink YouTube Channel",
|
"Unlink YouTube Channel": "Unlink YouTube Channel",
|
||||||
"Sign In With YouTube": "Sign In With YouTube",
|
"Sign In With YouTube": "Sign In With YouTube",
|
||||||
"There was an error with LBRY first publishing.": "There was an error with LBRY first publishing.",
|
"There was an error with LBRY first publishing.": "There was an error with LBRY first publishing.",
|
||||||
"Automagically upload to your youtube channel.": "Automagically upload to your youtube channel."
|
"Automagically upload to your youtube channel.": "Automagically upload to your youtube channel.",
|
||||||
|
"--end--": "--end--"
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,12 @@ function saveMessage(message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!knownMessages[message]) {
|
if (!knownMessages[message]) {
|
||||||
|
const END = '--end--';
|
||||||
|
delete knownMessages[END];
|
||||||
knownMessages[message] = message;
|
knownMessages[message] = message;
|
||||||
fs.writeFile(messagesFilePath, JSON.stringify(knownMessages, null, 2), 'utf-8', err => {
|
knownMessages[END] = END;
|
||||||
|
|
||||||
|
fs.writeFile(messagesFilePath, JSON.stringify(knownMessages, null, 2) + '\n', 'utf-8', err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue