only set the locale if it is a valid locale