It took me a couple of minutes to understand the report, but I think I understood it :)
Does this happen in a current version of Pywikibot? If not, can you please update and try again?
Current version (downloaded 18 dec 22). I tried adding message manually in i18n/en.json but its just pops up new error message
18 dec 22 is not so new. Please try updating from Gerrit and running again.
I'm really not a big expert on pywikibot, but from what I know, its users usually update from Gerrit and rely more on the Gerrit version number based on the last commit. If you got pywikibot from Gerrit, you can check it by running
git log -1.
As far as I can see, the usage of the message "cosmetic_changes-append" has changed recently, and I think that if you update to the latest version from Gerrit, the problem will be fixed.
If you try this and it's still not fixed, then I'll try to involve pywikibot developers.
The "cosmetic_changes-append" message was replaced with "pywikibot-cosmetic-changes" message in Pywikibot 7 and was removed in Pywikibot 8, see https://doc.wikimedia.org/pywikibot/stable/changelog.html#will-be-removed-in-pywikibot-8. This problem may happen if you have updated the i18n files but your Pywikibot release is older than 7.0.0. I propose to update the Pywikibot to the current stable version (7.7.2).
My previous answer is wrong. The translation of Pywikibot 7+ does not work as expected. The i18n.twtranslate() function raises that exception even a fallback is given; this is not intentional and is a real bug. I'll fix it soon. See phab:T326470.