Elrond identified the swords by their runes in The Hobbit:
Elrond knew all about runes of every kind. That day he looked at the swords they had brought from the trolls’ lair, and he said: ‘These are not troll-make. They are old swords, very old swords of the High Elves of the West, my kin. They were made in Gondolin for the Goblin-wars. They must have come from a dragon’s hoard or goblin plunder, for dragons and goblins destroyed that city many ages ago. This, Thorin, the runes name Orcrist, the Goblin-cleaver in the ancient tongue of Gondolin; it was a famous blade. This, Gandalf, was Glamdring the Foe-hammer that the king of Gondolin once wore. Keep them well!
I can't tell whether those in Gondolin used Quenya or Sindarin, but it seems very likely Gandalf could read and speak whatever language they used, and thus was on the sword. This answer describes the languages Gandalf knew, which includes them.
They even noticed the runes before bringing them to Elrond, but couldn't read them:
‘These look like good blades,’ said the wizard, half drawing them and looking at them curiously. ‘They were not made by any troll, nor by any smith among men in these parts and days; but when we can read the runes on them, we shall know more about them.’
It has always seemed odd to me that Gandalf who, in the Lord of the Rings, was a very learned loremaster, somehow didn't recognize either of these "famous blades", one of which was actually the king's sword. They needed Elrond to identify them. Heck, even the goblins in the Misty Mountains recognized them on sight:
The Great Goblin gave a truly awful howl of rage when he looked at it, and all his soldiers gnashed their teeth, clashed their shields, and stamped. They knew the sword at once. It had killed hundreds of goblins in its time, when the fair elves of Gondolin hunted them in the hills or did battle before their walls. They had called it Orcrist, Goblin-cleaver, but the goblins called it simply Biter.
This sword’s name was Glamdring the Foe-hammer, if you remember. The goblins just called it Beater, and hated it worse than Biter if possible.
They came scurrying round the corner in full cry, and found Goblin-cleaver, and Foe-hammer shining cold and bright right in their astonished eyes. The ones in front dropped their torches and gave one yell before they were killed. The ones behind yelled still more, and leaped back knocking over those that were running after them. ‘Biter and Beater!' they shrieked
Is this a continuity error because The Hobbit was written and published before the full character of Gandalf was imagined?