On the role of gradients in the localization of deformation and fracture