I never heard how in happened, but Mark Twain was apparently quite fluent in German.
Here's a tidbit from "engines" episode 1064;
When Mark Twain's Connecticut Yankee at King Arthur's
Court uttered a bogus magic spell, he used a long German
word:
Konstantinopelitanischerdudelsachspfeifenmachersgesellschaft.
It means an "organization of bagpipe makers from
Constantinople." Should we regard that as six words or just
one?

I like the sound of "dudelsach" much better than "bagpipes".