Set locale in template instead of JavaScript
No need to pass locale
Execute code only if an error occures
No need to empty cached iframe, it's reloaded anyways
Reorganization and cleanup