improved set_locale method