use espeak_ng::Translator;
fn tr(lang: &str) -> Option<Translator> {
Translator::new(lang, None).ok()
}
#[test]
fn cyrillic_word_switches_to_russian() {
let (Some(en), Some(_ru)) = (tr("en"), tr("ru")) else {
eprintln!("[SKIP] no en/ru data");
return;
};
let out = en.text_to_ipa("hello мир").unwrap();
assert!(out.contains("(ru)"), "Cyrillic word should switch to ru: {out}");
assert!(out.contains("həlˈəʊ"), "the English word still reads: {out}");
assert!(en.text_to_ipa("Привет world").unwrap().contains("(ru)"));
if tr("el").is_some() {
let g = en.text_to_ipa("the word Αθήνα").unwrap();
assert!(g.contains("(el)"), "Greek word should switch to el: {g}");
}
}
#[test]
fn native_and_latin_scripts_do_not_switch() {
if let Some(ru) = tr("ru") {
assert!(!ru.text_to_ipa("мир").unwrap().contains("(ru)"), "ru reads Cyrillic natively");
}
if let Some(en) = tr("en") {
assert!(!en.text_to_ipa("café").unwrap().contains("(ru)"), "Latin word not switched");
}
}