Lagrangian dynamics on an infinite-dimensional torus: a Weak KAM theorem