Pig Latin (or Igpay Atinlay in Pig Latin) is an English language game that is mainly popular with young children. They like to use it as a secret language for amusement or to converse in perceived privacy from other persons. The reference to Latin is a deliberate misnomer. It is simply a form of jargon, used only for its English connotations as a strange and foreign-sounding language.
The usual rules to convert English words into Pig Latin are as follows:
For words that begin with a vowel the suffix -way is added at the end of the word.
For words that begin with a series of consonants, the initial consonant cluster is moved to the end of the word and the -ay is appended. In case the letter u is preceded by the letter q, the letter u is also considered to be a consonant.
If the first letter of the word was an upper case letter, the first letter of the transformed word should also be converted into upper case. If the first vowel of the word is lower case and the first letter of the word is a consonant, that consonant needs to converted into lower case in the transformed word. For all other letters, the use of lower and upper case letters is retained.
Write a function pigword that takes a word as a string argument. The word should only contain letters. The function must return the transformed word according to the rules of Pig Latin. Keep in mind the rules for upper case and lower case letters as described above.
Write a function piglatin that translates a given sentence into Pig Latin version. This is done by translating the individual words of the sentence according the rules of Pig Latin. Words are defined as the longest possible sequence of letters. All characters of the sentence that are not letters (punctuation marks, digits, white space, …) must remain unchanged in the translated sentence.
>>> pigword('egg')
'eggway'
>>> pigword('Pig')
'Igpay'
>>> pigword('Latin')
'Atinlay'
>>> pigword('trash')
'ashtray'
>>> pigword('quit')
'itquay'
>>> pigword('BaNaNa')
'ANaNabay'
>>> pigword('DNa')
'AdNay'
>>> pigword('plover')
'overplay'
>>> pigword('plunder')
'underplay'
>>> piglatin('And now for something completely different!')
'Andway ownay orfay omethingsay ompletelycay ifferentday!'
>>> piglatin('Stwike him, centuwion, stwike him vewy wuffly')
'Ikestway imhay, entuwioncay, ikestway imhay ewyvay ufflyway'
Among other "languages", Google provides an option for displaying the site in Pig Latin1. Images becomes Imagesway, Blogger becomes Oggerblay, and Sign In becomes Ignsay Inway.
When you're a traveling pig, you need a good phrasebook. Estonian pigs go rui, French groin, Polish chrum, and Czech, improbably, chro. English pigs have been oinking only since 1940. And in Rome, presumably, they speak Pig Latin.