Refactoring locale handling