Improve failure handling when setting the locale