Exponential localization of wavefunctions in lattices, whether in real or synthetic dimensions, is a fundamental wave interference phenomenon. Localization of Bloch-type functions in space-periodic lattice, triggered by spatial disorder, is known as Anderson localization and arrests diffusion of classical particles in disordered potentials. In time-periodic Floquet lattices, exponential localization in a periodically driven quantum system similarly arrests diffusion of its classically chaotic counterpart in the action-angle space. Here we demonstrate that nonlinear optical response allows for clear detection of the disorder-induced phase transition between delocalized and localized states. The optical signature of the transition is the emergence of symmetry-forbidden even-order harmonics: these harmonics are enabled by Anderson-type localization and arise for sufficiently strong disorder even when the overall charge distribution in the field-free system spatially symmetric. The ratio of even to odd harmonic intensities as a function of disorder maps out the phase transition even when the associated changes in the band structure are negligibly small.