(WIP) Refactoring i18n.js file.

_Do not merge yet!_

**Description**

First of all, this file is very messy from the point of view of nicely written JavaScript. Second of all it is missing tests.

**Reviewers**
- none assigned yet