David Salo is an expert in languages that exist only in the imaginary world of hobbits and elves.

He has immersed himself in Quenya and Sindarin, languages created by author J.R.R. Tolkien for the inhabitants of Middle-earth and featured in his The Lord of the Rings trilogy.

So when filmmakers adapting the fantasy epic wanted to translate parts of their script from English into the two Elvish languages, they turned to Salo, a graduate student in linguistics at the University of Wisconsin-Madison.

"I know it a lot better than most of the foreign languages I've studied," the 32-year-old said.

Salo, who is studying Tocharian, an Indo-European language spoken in medieval China, said his interest in Tolkien's languages started at age 6 or 7, when he began reading The Lord of the Rings.

The story follows hobbit Frodo Baggins on a harrowing journey, under the guidance of the wizard Gandalf, to destroy the all-powerful ring that the dark lord Sauron covets.

"All these neat names and words and you want to know, what do they mean?" Salo said. "Some of them Tolkien explains, and some of them he doesn't say anything about."

In the seven years between his undergraduate studies at Macalester College in St. Paul, Minn., where he studied Latin and Greek, and graduate school in Madison, Salo learned everything he could about Tolkien's Elvish languages.

Three years ago, when he heard about plans to turn The Lord of the Rings into a movie, he wrote director Peter Jackson and the film's producers. His letter made two points: It was important to get Tolkien's Elvish languages right, and Salo could help.

A few months later, the producers called.

"I was shocked," he said.

Before the film began shooting in New Zealand, Salo worked with set and costume designers, writing short verses that could be inscribed on swords and other props.

Tolkien created many languages, but the two most important were Quenya and Sindarin, which Salo said are related to each other in much the same way English and German are.

Quenya mostly resembles an ancient form of Greek, while Sindarin is modeled on Welsh, Salo said. But Tolkien took "bits and pieces from all over," including Latin, Finnish and Hebrew.

Some sample words: In Sindarin, the word for hobbit is periain (pronounced peri'-ain), ang is iron, duath means darkness; hir means lord. In Quenya, parma means book, anga is iron, heru is lord, lumbule is darkness.

Translating the dialogue took some educated guesses on Salo's part, since Tolkien never published a guide.

"He gives little hints here and there. So you look at that, you look at the patterns and you extrapolate," Salo said. "You can sort of work out a good deal of the grammar and predict some things that most people would think you couldn't predict."

Once hired, Salo sent a tape of himself speaking the Elvish languages to Andrew Jack and Roisin Carty, the film's dialect and language coaches, so they could teach the actors, including Cate Blanchett, Ian McKellen, Liv Tyler and Elijah Wood.

The filmmakers relied on Salo throughout the 15-month shoot, which included making parts two and three, due in theaters in 2002 and 2003.

"They would suddenly call me up at midnight ... and say, 'We need you to write us a line of dialogue for the shooting tomorrow,"' Salo said.

He said it wouldn't take him long to comply. "When you've been working with this for awhile, it becomes like a second language."