In its first appearance, the universal translator was stated to be able to scan brainwave patterns. From
TOS: "Metamorphosis":
(Spock is working on the Universal Translator. It is basically a metal tube nearly a foot long, that can be held in the hand.)
COCHRANE: What's the theory behind this device?
KIRK: There are certain universal ideas and concepts common to all intelligent life. This device instantaneously compares the frequency of brainwave patterns, selects those ideas and concepts it recognises, and then provides the necessary grammar.
SPOCK: Then it translates its findings into English.
COCHRANE: You mean it speaks?
KIRK: With a voice or the approximation of whatever the creature is on the sending end. Not one hundred percent efficient, but nothing ever is. Ready, Mister Spock?
SPOCK: Quite ready, Captain.
KIRK: Mister Cochrane, call the Companion.
There may be multiple versions of the universal translator device, such as for use at long range that don't do the brainwave scanning. The brainwave scanning could be needed primarily to learn new languages and not be as necessary to do, say, verbal translation over subspace radio.
There's also the concept of
linguacode introduced in TMP. It could also be that long-range communication routinely involves the sender doing some of the heavy lifting by translating the message into a universal code that assists the receiver's translation. But that's really another topic.