This might seem like a simple question, but I believe the answer isn't so simple. One might think that lines of dialogue are only directly translated, as though the script is run through Google Translate or something, but that's barely the case.
Think of how when you switch between different audio-tracks of the DVD of a foreign-language film, they still line up perfectly. Even though translated text rarely has the same amount of syllables as the original, the dialogue still feels rightly paced, and not awkward.
Even tonally, the dialogue fits the situation and/or the mood of the film. There's an idea that well-known phrases or clever jokes in a given language never translate well into another. Cleverly written dialogue tends to lose its essence. However, this "lost-in-translation" theory doesn't seem to apply for dubbed movies (or at least the ones that are considered "properly dubbed", such as Spirited Away).
If you want dialogue that syncs perfectly with the lips, then you'd have to sacrifice its original essence. And if you care about the original essence, you'd have to trade off the lip-sync.
So how exactly do production companies dub movies into different languages?