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

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

Uses the suffix and special_case_suffix “ay” and “way” 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_way;

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

translate_way(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_way(b"This library can translate any English text. It can even handle multiple sentences!", &mut buffer);
assert_eq!(&buffer, b"Isthay ibrarylay ancay anslatetray anyway Englishway exttay. Itway ancay evenway andlehay ultiplemay entencessay!");

buffer.truncate(0);
translate_way(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 edgeway asescay. Atthay isway away ontractioncay, asway ellway asway away ordway erewhay ethay onlyway owelvay isway yway. Eatnay, allway atthay orksway!");

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

buffer.truncate(0);
translate_way(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_way(b"Hello-world", &mut buffer);
assert_eq!(&buffer, b"Ellohay-orldway");

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

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