Pig Latin is the playground language everyone half remembers. “Hello” becomes “ellohay”, “pig” becomes “igpay”, and “Latin” becomes “atinlay”. It is not Latin and has nothing to do with pigs; the name is a joke about it sounding like a garbled version of a classical tongue. Children have used it for generations as a way of talking in front of adults, and it remains a favourite for first programming exercises.
Type English text and the tool translates every word as you type.
The rules it follows
For a word that begins with a consonant, all of the consonants before the first vowel move to the end of the word, and “ay” is added: “string” becomes “ingstray”, “smile” becomes “ilesmay”. For a word that begins with a vowel, there is nothing to move, so an ending is added instead. The usual choice is “way” (“apple” becomes “appleway”), but “yay” and “ay” are also common, and the tool lets you pick.
A “qu” at the start counts as one unit, as it sounds like a single consonant: “quick” becomes “ickquay” and not “uickqay”. The letter y counts as a consonant at the start of a word, so “yellow” becomes “ellowyay”.
Capitals are kept: the first letter of the translation is capitalised if the original was, and a word written entirely in capitals stays in capitals. Punctuation and digits are left alone and stay in place.
What it cannot do well
There is no single official version of Pig Latin, and different people apply different rules. Some add “way” to vowel words, some “yay”, some “hay”, and a few move only the first letter. The tool sticks to the common version, and if your teacher or your game uses another, you may need to adjust a few words by hand.
Words with an apostrophe are treated as two words, since the apostrophe splits them, so “don’t” becomes “onday’tay”. Hyphenated words are translated part by part. Numbers and symbols are left alone, and so are words from other languages if they use letters outside the English alphabet; only letters are translated, using English vowel rules.
Translating back
The tool translates English to Pig Latin only. Going the other way cannot be done reliably by a program, because the translation loses information: “ayway” could be “way”, “away” or “yay” depending on the rules and the word, and “ightnay” could be “night” or “gnight”. People manage it by knowing the language, which is the part that makes the game fun.
Other codes and word games
For other ways to scramble text, there is the Caesar cipher, which shifts letters, Morse code, and the text reverser, which writes words backwards. The NATO phonetic alphabet is a spelling code and an easy partner for a game of secret messages. And if you are building your own translator as a coding exercise, the rules above are the specification: test against the results here.