This was done by looking at characters listed on the Wikipedia language recognition chart[0] for each language, finding the last character in the array that the language uses and splitting the rest off into misc. This was partially automated, but there is potential that there may be errors for some languages. All of the keys should still be there if misc keys are enabled, so the keyboard should still be usable for all affected languages even if there were errors, if misc keys are enabled.
[0] https://en.wikipedia.org/wiki/Wikipedia:Language_recognition_chart
The texts for more keys have been updated:
* morekeys_a should now include only letters relevant to the active language
* morekeys_misc_a should include misc letters (accents, etc) not specifically needed for typing in the language
The above still needs to be applied to most other languages. Only QWERTY has been updated with the new morekeys system. Other layouts still need to be updated.
The Python version uses json files, separate from the xml files. Comments haven't been migrated still.
I'm still not very happy with the way the keyboard texts are managed and that it requires running a separate tool to generate a .java file. It's at least better than manually editing an autogenerated file as before, and python3 is more widely available than the archaic Android build system