Googol: English To 'Pig Latin'
1) For words that begin with 'consonant' sounds, move the initial consonant or consonant cluster to the end of the word and add "ay."
Ex: English: Zeitgeist ------ Pig Latin: eitgeistzay
2) For words that begin with vowel sounds (including silent consonants), simply add the syllable "ay" to the end of the word.
Ex: Englsih: Algorithm ------ Pig Latin: Algorithmway
Read full article from Googol: English To 'Pig Latin'
1) For words that begin with 'consonant' sounds, move the initial consonant or consonant cluster to the end of the word and add "ay."
Ex: English: Zeitgeist ------ Pig Latin: eitgeistzay
2) For words that begin with vowel sounds (including silent consonants), simply add the syllable "ay" to the end of the word.
Ex: Englsih: Algorithm ------ Pig Latin: Algorithmway
public
class
EnglishToPigLatinTranslator {
public
static
void
main(String[] args) {
System.out.println(
"Enter The English Phrase To Be "
+
"Translated Into 'Pig Latin' : "
);
Scanner scanner =
new
Scanner(System.in);
String strEngPhrase = scanner.nextLine();
if
(strEngPhrase !=
null
&& !strEngPhrase.equals(
""
)) {
System.out.println(
"\nPig Latin Text : \n"
+
convertEnglishToPigLatin(strEnglishPhrase));
}
else
{
System.out.println(
"No Input Specified!"
);
}
}
public
static
String convertEnglishToPigLatin(String strEnglishPhrase) {
String strVowels =
"aeiou"
;
String[] strTokens = strEnglishPhrase.split(
"[ ]"
);
StringBuffer sbPigLatinStuff =
new
StringBuffer();
for
(
int
i=
0
;i<strTokens.length;i++) {
if
(strVowels.indexOf(strTokens[i].charAt(
0
)) >=
0
) {
sbPigLatinStuff.append(strTokens[i] +
"way "
);
}
else
if
((strTokens[i].indexOf(
"a"
) <
0
) &&
(strTokens[i].indexOf(
"e"
) <
0
) &&
(strTokens[i].indexOf(
"i"
) <
0
) &&
(strTokens[i].indexOf(
"o"
) <
0
) &&
(strTokens[i].indexOf(
"u"
) <
0
)) {
sbPigLatinStuff.append(strTokens[i] +
"ay "
);
}
else
{
for
(
int
j=
1
;j<strTokens[i].length();j++) {
if
(strVowels.indexOf(strTokens[i].charAt(j)) >=
0
) {
sbPigLatinStuff.append(strTokens[i].substring(j) +
strTokens[i].substring(
0
,j) +
"ay "
);
break
;
}
}
}
}
return
sbPigLatinStuff.toString();
}
}
Read full article from Googol: English To 'Pig Latin'