The foreign actors' voices have to match the age, texture, and comedic sense of the original. For a big celebrity such as Johnny Depp or Jim Carrey, a single actor in each country will dub all of the star's films. Koichi Yamadera, for instance, is the official Jim Carrey of Japan. Studios also sometimes employ local celebrities, like when Disney hired the French singer Charles Aznavour to do the voice of Ed Asner's protagonist in the movie Up. On rare occasions, the original actor will do the dubbing himself. Viggo Mortensen speaks Spanish, so he did a Spanish dub for Hidalgo. For the Castilian dub of G-Force, Penélope Cruz was unavailable, so her sister, Monica Cruz, got the job instead.
The mechanics of the process are also explained, as well as tricks some voice actors use to tweak their performance. Link