The TARDIS provides a telepathic translation service for those who travel in her. This was first revealed in "The Masque of Mandragora", and has been restated (at least in part) in several stories but the clearest demonstration is in "The Christmas Invasion". In that story, the translation service doesn't work while the Doctor is disabled by his regeneration trauma & resumes when he recovers.
The same story also shows that translation of speech is provided for all those participating in the conversation, not just for the TARDIS inhabitants themselves.
The translation service also works on writing, although it's not been made clear if that aspect of the service is provided to others. ("The Fires of Pompeii".)
There are some languages which the TARDIS can't translate, because they are too old. ("The Impossible Planet"/"The Satan Pit".) The TARDIS also doesn't translate Judoon, for reasons unknown ("The Stolen Earth").
Gallifreyan isn't translated but it's never been stated whether the TARDIS is unable to translate it or is forbidden to do so. ("A Good Man Goes to War".)
The franchise has not made clear if the "gift" of translation is permanent or temporary, given the number of companions who have been left behind in places where they may not natively know the language (i.e. Vicki, Steven Taylor, Leela, Nyssa, Peri, Mel, among others).