Gandalf translates the entire statement, including the password, nearly as soon as the Fellowship sees them. Initially the inscription, and the entire engraving, is invisible, and Gandalf needs a spell to make it visible:
'Well, here we are and all ready,' said Merry; 'but where are the Doors? I can't see any sign of them.'
'Dwarf-doors are not made to be seen when shut,' said Gimli. 'They are invisible, and their own masters cannot find them or open them, if their secret is forgotten.'
'But this Door was not made to be a secret known only to Dwarves,' said Gandalf, coming suddenly to life and turning round. 'Unless things are altogether changed, eyes that know what to look for may discover the signs.' ...
'Look!' he said. 'Can you see anything now?' ... Slowly on the surface, where the wizard's hands had passed, faint lines appeared, like slender veins of silver running in the stone. At first they were no more than pale gossamer-threads, so fine that they only twinkled fitfully where the Moon caught them, but steadily they grew broader and clearer, until their design could be guessed.
At the top, as high as Gandalf could reach, was an arch of interlacing letters in an Elvish character.
Frodo asks Gandalf what the writing says, and Gandalf translates it:
'The words are in the elven-tongue of the West of Middle-earth in the Elder Days,' answered Gandalf. 'But they do not say anything of importance to us. They say only: The Doors of Durin, Lord of Moria. Speak, friend, and enter. And underneath small and faint is written: I, Narvi, made them. Celebrimbor of Hollin drew these signs.'
There's no particular reason for Legolas to intervene and tell everyone what the translation is: Frodo is specifically asking Gandalf, and Gandalf understands Sindarin well enough to translate. (He certainly knows what the Elvish for "friend" is. It's likely, though not certain, that Frodo does too.) It is possible, as well, that Legolas, like Frodo, doesn't recognize this particular method of writing—there were many different methods of writing the Elvish languages, and not all were mutually understandable.
No one, at this point—not Gandalf, not Frodo, not Legolas—realizes that the password is hidden in the inscription. It takes quite a while for Gandalf to realize the device:
He stepped up to the rock again, and lightly touched with his staff the silver star in the middle beneath the sign of the anvil.
Annon edhellen, edro hi ammen!
Fennas nogothrim, lasto beth lammen!
he said in a commanding voice. The silver lines faded, but the blank grey stone did not stir. ... The cliff towered into the night, the countless stars were kindled, the wind blew cold, and the doors stood fast.
Finally, Gandalf figures it out:
With a suddenness that startled them all the wizard sprang to his feet. He was laughing! 'I have it!' he cried. 'Of course, of course! Absurdly simple, like most riddles when you see the answer.'
Picking up his staff he stood before the rock and said in a clear voice: Mellon!
The star shone out briefly and faded again. Then silently a great doorway was outlined, though not a crack or joint had been visible before. Slowly it divided in the middle and swung outwards inch by inch, until both doors lay back against the wall.
Neither Frodo nor Legolas contributes to this whole process, because (although they certainly know the meanings of the words involved) they don't have any idea of the trick behind the password.
All quotes from The Lord of the Rings, Book II, Chapter 4, "A Journey in the Dark".