Jacopo Prisco , CNN Written by

"Dracarys!" says Daenerys Targaryen to Drogon, her young dragon, ordering him to spit fire on an incredulous enemy who gets torched alive.

This scene from the third season of "Game of Thrones" is the stuff of legends for fans of the HBO show, and a pivotal moment in the story: Daenerys -- played by Emilia Clarke -- is about to take control of an 8,000-strong slave army by trading one of her dragons for it, while Kraznys, a slave trader and the master of that army, throws insults at her thinking she doesn't understand his language, Valyrian.

But, in a stunning reveal, Daenerys suddenly starts speaking fluent Valyrian. She understood every word and the trade is just a trick: "Dracarys" means "dragon fire," and moments later, Kraznys is toast. "Kesy tubi jemot dāervi tepan," she tells the slaves afterward -- "Today I give you freedom."

It may look like gibberish, but all the lines spoken in Valyrian -- a language split into many dialects and across various regions of the "Game of Thrones" world -- are linguistically correct. They were written by linguist David J. Peterson, who has created over 50 fictional languages, mostly for movies and TV shows. He constructed Valyrian like a real language nearly from scratch, complete with grammar and rules. All he had to build upon was a handful of words and sentences that author George R. R. Martin included in his "A Song of Ice and Fire" books, from which the series is adapted, such as "Valar morghulis" ("All men must die") and "Valar dohaeris" ("All men must serve").

How to speak like a true Targaryen from 'Game of Thrones'

Competition winner

Peterson also designed another of the fictional languages heard throughout "Game of Thrones": Dothraki, which is spoken by Jason Momoa's character Khal Drogo and his tribe. The linguist developed this language first, in response to an online competition launched by the show's producers before the series first aired.

"Game of Thrones" stars Jason Momoa and Emilia Clarke. Credit: Frazer Harrison/Getty Images North America/Getty Images for AFI

"I applied, with many other very good language creators," Peterson said in a phone interview. "The competition had no upper limit on the amount of material you could provide. When I learned that, I spent every single minute of every day working on my proposal -- up to 18 hours a day sometimes. In about a month, I created over 300 pages of material, including grammar, translations and cultural phrases."

He won the competition, and was later asked to create Valyrian too. Today, Dothraki has about 4,000 official words, and Valyrian about 2,000. Popular online learning platform Duolingo has even included High Valyrian -- the noblest of Valyrian dialects, as spoken by Daenerys -- in its offerings, and to date 1.2 million learners have started the course. It is particularly popular in the UK, where 100,000 people have signed up to study it -- more than can speak traditional languages like Irish and Scottish Gaelic, according to Duolingo.

Daenerys Targaryen is a native speaker of High Valyrian. Credit: Helen Sloan/HBO

How to make a language

How long does it take to design a functional constructed language? According to Peterson, it takes six months to a year to get the grammar up and running, but the speed of TV and movie production means he gets far less than that.

Time is not the only factor at play, however. "The thing with a language is that it's not actually a physical entity, so you can, in theory, create the whole thing in your head. But will you remember it? What takes time is making those decisions and then writing them down in a way that you're going to be able to access later," he said.

A scene from "Game of Thrones." Credit: Helen Sloan/HBO

Nevertheless, it all starts with the grammar. It's not just a matter of deciding which sounds to use, but how they fit together into syllables and then words. "Once you have that information, you can generate, either manually or with a program, a basically infinite number of allowable possible word forms," Peterson explained. You can do the same thing in English right now ... "Blick" could be a word. It doesn't happen to be, but it could be a fine English word."

Distance learning

To help "Game of Thrones" actors speak Dothraki and Valyrian correctly, Peterson records audio versions of each line, so the performers have a model to follow. Usually, the process starts with Peterson receiving the full scripts, although this hasn't happened for the current season -- the eighth, and last, of the series -- presumably due to a heightened need for secrecy.

And the linguist does have a favorite in the cast: "Jacob Anderson (who plays the Unsullied Grey Worm ) is the best performer I've ever seen in a created language. I've worked in a lot of stuff, and he is still far and away the best. I love hearing him speak," Peterson said.

Actor Jacob Anderson, who plays Grey Worm in "Game of Thrones." Credit: Charles McQuillan/Getty Images Europe/Getty Images

Constructed languages, or "conlangs," have grown in popularity since the inception of the internet, which has given learners easy ways to find one another and platforms to expand their vocabulary. Among the best-known fictional languages, Klingon from "Star Trek" has enjoyed a cult following since the 1990s and its creator, Mark Okrand, regularly releases new words.

It, too, is available on Duolingo, and is one of several conlangs for which ample online resources are available, along with Na'vi from the 2009 blockbuster "Avatar" and Elvish from J. R. Tolkien's "Lord of the Rings" saga.

David J. Peterson, the linguist behind the Valyrian and Dothraki languages.

While learning a fictional language may have little practical value, it offers a way for people to connect with their passions and interact with like-minded individuals. And it does have other benefits, according to Peterson.

"Studying a created language that nobody speaks is not really going to help you with communicating with somebody else," he admitted. "But it does improve your ability to learn a language. You're engaging the same part of your brain. And the more languages you study, the easier it gets to study yet another one."