Optical switching of nuclear spin–spin couplings in semiconductors