Move translate-specific code from main.js to translate.js