A nonlinear Galerkin method for the shallow-water equations on periodic domains