The arithmetic theory of loop groups. II: The Hilbert-modular case Cohomology of Drinfeld modular varieties. Part II: Automorphic forms, trace formulas and Langlands correspondence. With an appendix by Jean-Loup Waldspurger 