Profile statements i18n

Implements #2669 and closes #1659. Also refactors and cleans up a lot of stuff, including some of the JS code.
Nice.