A weak convergence approach to large deviations for stochastic approximations