Set locale from param, session or header

Fix some existing errors and additionally get the locale from the header etc as needed.