'Ash nazg' and so on
...but how do we know it?
I was thinking about the ring verse and where it came from, or rather: what way did it came from Sauron all the way to Elven lore, and I checked the book, and surprisingly! it's more clear than I have expected.
So, for the first part (the part written on the ring):
Out of the black Years come the words that the Smiths of Eregion heard, and knew that they had been betrayed. ("the Council of Elrond" chapter)
Not only Celebrimbor, but (according to Gandalf) more smiths have heard the spell when Sauron was casting it. I'm not sure why anyone not wearing a Ring of Power would hear it, and I'm not sure the lesser rings would have this effect... How certain we are that Celebrimbor kept all 3 to himself at the time? TG suggests that he generally made them with other smiths, so it would make sense that more people wore them.
Anyway Celebrimbor, and maybe some others, heard the spell... in their minds, I would assume (and so quoth Tolkien Gateway), and in Tolkien's world thoughts have no inherent language (because he wasn't, I guess, usually thinking in words...) so there was no issue of 'they heard the Black Speech and didn't understand it'.
And then the second part was added by the Elves, after they learned what happened to the other rings, because Elves like making poems.
But now there is a question to be asked:
If the verse existed in Elvish lore only in the Elvish language version, how did Gandalf recognize it?
Does Gandalf know Black Speech? (I don't think he automatically knows all languages, even as a full-on Maia. I don't think they do it.) If so, where from? (My bet would be on Saruman learning it 'to fight Sauron better' --- but then why would he share the knowledge? Maybe early on he did?)
Does Gandalf only know what it means from Isildur's notes ---- but then, how did Isildur know Black Speech?
Did Isildur (or Gandalf) simply notice that there are three parts starting with the same phrase, and rhymes, and guessed what it was because what else would be written on the ring, if not the ring-spell?
Also, the word "nazgh" was easy to guess, because the nazgul were called that... were they called that even in the times of Isildur? And btw it's funny how the orkish name for them became common --- or was in the name they used? "Hi, we are the Nazgul"???
But if it's just a guess-translation, and he doesn't speak the language, how would Gandalf know how to pronounce the Black Speech version? The Tengwar is quite arbitrary: various modes use various consonants and without knowing the mode you can't read it properly. (And from what I know, the ring verse is spelled weirdly anyway)
I was thinking about this in a shower and a thought occurred to me, brilliant in the crack-but-may-be-canon way:
In Bag End, Gandalf says "the language of Mordor which I will not utter here". But in Rivendell, he utters it with no problem.
I've been assuming that it's because Rivendell is shielded by Wilya so it's safe to quote the spell there, and Gandalf wants to shock the Elves into action etc. It never felt quite right.
Where is Gandalf between these two scenes? Talking with Saruman, and unlike in the movie, there is probably a pretense of politeness going on between them. So, an idea:
Gandalf realizing that he is trapped and deciding to get as much of it as he can, asks Saruman "by the way you surely can read Black Speech, I wonder do you know the spell that is engraved on the Ring?"
And Saruman (whom Sauron has taught his conlang, of course), hoping to flex his Ring-lore and maybe in this way convince Gandalf to join him, goes "Ash nazg durbatulûk, ash nazg gimbatul, ash nazg thrakatulûk, agh burzum-ishi krimpatul"
Gandalf takes mental notes
He returns to safety and goes to Elrond
And while before, with Frodo, Gandalf had to hide his lack of linguistic knowledge behind propriety ('I will not read it because it's Evil, and totally not because I can't or something'), now in Rivendell he can finally speak the verse.
Ha! Behold, I am Gandalf the Grey, Speaker of Many Languages :D
...turns out it *does* freak people out actually. Well. At least they are now more motivated.
(And Elrond is like 'if you don't shut up, I'm going to out you as a Maia and accuse you of being corrupt' --- that's kinda how his reply reads to me)
No wait, I can do better!
Even with the above, Gandalf reciting the original ring spell in Rivendell, while wearing one of the Elven Rings and being near another, and *the* ring is nearby too... this seems like an unnecessary risk, and always felt a bit out-of-character to me, even with his mischievous tendencies.
Saruman was known for the ability to manipulate others with his voice. And he'd spent weeks with Gandalf, trying to convince him (I would assume) to his case. And while Gandalf was definitely not convinced, what if something stuck? What if it was Saruman who planted the ring verse deeply in his mind, to somehow corrupt Gandalf, and then, as a result, it seemed to him like a good idea to show off by reciting it?
(IK the doylist reason is just "Tolkien wanted to show off his evil language". But anyway.)
Also, imagine Gandalf sitting in the tower while Saruman is chanting the ring verse all the time.