// Package piglatin translates from English to Pig Latin.
package piglatin
import "strings"
var vowels = []string{"a", "e", "i", "o", "u", "xr", "yt"}
var consonants = []string{"rh", "sch", "thr", "th", "squ", "ch", "qu", "b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z"}
// Sentence converts input sentence to Pig Latin sentence.
func Sentence(input string) string {
out := strings.Builder{}
for i, word := range strings.Split(input, " ") {
if i != 0 {
out.WriteRune(' ')
}
vowel := false
for _, vow := range vowels {
if strings.HasPrefix(word, vow) {
out.WriteString(word + "ay")
vowel = true
break
}
}
if !vowel {
for _, cs := range consonants {
if strings.HasPrefix(word, cs) {
out.WriteString(word[len(cs):] + cs + "ay")
break
}
}
}
}
return out.String()
}