pub fn translate_yay(english: &[u8], pig_latin_string: &mut Vec<u8>)
Expand description

Translates a multi-word string (including punctuation) into Pig Latin (yay-style)!

Uses the suffix and special_case_suffix “ay” and “yay” respectively when calling translate_with_style().

Note: The resulting translation is appended to the provided buffer, so one may wish to ensure it is cleared before each use or not depending on the application.

Examples

use anslatortray::byte_string::translate_yay;

let mut buffer = Vec::<u8>::new();

translate_yay(b"Hello world from the coolest Pig Latin translator!", &mut buffer);
assert_eq!(&buffer, b"Ellohay orldway omfray ethay oolestcay Igpay Atinlay anslatortray!");

buffer.truncate(0);
translate_yay(b"This library can translate any English text. It can even handle multiple sentences!", &mut buffer);
assert_eq!(&buffer, b"Isthay ibrarylay ancay anslatetray anyyay Englishyay exttay. Ityay ancay evenyay andlehay ultiplemay entencessay!");

buffer.truncate(0);
translate_yay(b"Let's try some edge cases. That is a contraction, as well as a word where the only vowel is y. Neat, all that works!", &mut buffer);
assert_eq!(&buffer, b"Etlay's ytray omesay edgeyay asescay. Atthay isyay ayay ontractioncay, asyay ellway asyay ayay ordway erewhay ethay onlyyay owelvay isyay yyay. Eatnay, allyay atthay orksway!");

buffer.truncate(0);
translate_yay(b"What if a word has no vowels, like this: bcdfghjklmnpqrstvwxz", &mut buffer);
assert_eq!(&buffer, b"Atwhay ifyay ayay ordway ashay onay owelsvay, ikelay isthay: bcdfghjklmnpqrstvwxzay");

buffer.truncate(0);
translate_yay(b"Cool, so the heuristics make pretty good guesses with what they're fed!", &mut buffer);
assert_eq!(&buffer, b"Oolcay, osay ethay euristicshay akemay ettypray oodgay uessesgay ithway atwhay eythay're edfay!");

buffer.truncate(0);
translate_yay(b"Hello-world", &mut buffer);
assert_eq!(&buffer, b"Ellohay-orldway");

buffer.truncate(0);
translate_yay(b"Hyphens-are-difficult-aren't-they?", &mut buffer);
assert_eq!(&buffer, b"Yphenshay-areyay-ifficultday-arenyay't-eythay?");

buffer.truncate(0);
translate_yay(b"The buffer isn't cleared by the translate function beforehand, ", &mut buffer);
translate_yay(b"so we can do something like this if we wish!", &mut buffer);
assert_eq!(&buffer, b"Ethay ufferbay isnyay't earedclay ybay ethay anslatetray unctionfay eforehandbay, osay eway ancay oday omethingsay ikelay isthay ifyay eway ishway!");