From 7feb123a45ce0b4f444d2f4ec4578de36263e1ca Mon Sep 17 00:00:00 2001 From: infiinte-persistence Date: Wed, 8 Jul 2020 13:27:07 +0800 Subject: [PATCH] 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--". --- static/app-strings.json | 3 ++- ui/i18n.js | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/static/app-strings.json b/static/app-strings.json index cce9baaad..9261b8b0c 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -1273,5 +1273,6 @@ "Unlink YouTube Channel": "Unlink YouTube Channel", "Sign In With YouTube": "Sign In With YouTube", "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--" } diff --git a/ui/i18n.js b/ui/i18n.js index b019e1510..470362649 100644 --- a/ui/i18n.js +++ b/ui/i18n.js @@ -26,8 +26,12 @@ function saveMessage(message) { } if (!knownMessages[message]) { + const END = '--end--'; + delete knownMessages[END]; 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) { throw err; }