refactor redirection and check valid locale

Signed-off-by: Martin Bastien <martin.bastien@studiofrenetic.com>