move middleware.locals only where it is needed and transform it into a common function, simplify translations and adds automatic language detection