This whole thing would be much better as a JS file, possibly `commonplace make_langpacks`. Let me know if you need help porting this.