#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
#[non_exhaustive]
pub enum Lang {
#[cfg(feature = "afrikaans")]
Afrikaans,
#[cfg(feature = "albanian")]
Albanian,
#[cfg(feature = "assamese")]
Assamese,
#[cfg(feature = "belarusian")]
Belarusian,
#[cfg(feature = "bengali")]
Bengali,
#[cfg(feature = "bulgarian")]
Bulgarian,
#[cfg(feature = "catalan")]
Catalan,
#[cfg(feature = "croatian")]
Croatian,
#[cfg(feature = "czech")]
Czech,
#[cfg(feature = "danish")]
Danish,
#[cfg(feature = "dutch")]
Dutch,
#[cfg(feature = "english")]
English,
#[cfg(feature = "estonian")]
Estonian,
#[cfg(feature = "finnish")]
Finnish,
#[cfg(feature = "french")]
French,
#[cfg(feature = "galician")]
Galician,
#[cfg(feature = "georgian")]
Georgian,
#[cfg(feature = "german")]
German,
#[cfg(feature = "greek")]
Greek,
#[cfg(feature = "gujarati")]
Gujarati,
#[cfg(feature = "hindi")]
Hindi,
#[cfg(feature = "hungarian")]
Hungarian,
#[cfg(feature = "icelandic")]
Icelandic,
#[cfg(feature = "italian")]
Italian,
#[cfg(feature = "kannada")]
Kannada,
#[cfg(feature = "kurmanji")]
Kurmanji,
#[cfg(feature = "latin")]
Latin,
#[cfg(feature = "lithuanian")]
Lithuanian,
#[cfg(feature = "malayalam")]
Malayalam,
#[cfg(feature = "marathi")]
Marathi,
#[cfg(feature = "mongolian")]
Mongolian,
#[cfg(feature = "norwegian")]
Norwegian,
#[cfg(feature = "oriya")]
Oriya,
#[cfg(feature = "panjabi")]
Panjabi,
#[cfg(feature = "polish")]
Polish,
#[cfg(feature = "portuguese")]
Portuguese,
#[cfg(feature = "russian")]
Russian,
#[cfg(feature = "sanskrit")]
Sanskrit,
#[cfg(feature = "serbian")]
Serbian,
#[cfg(feature = "slovak")]
Slovak,
#[cfg(feature = "slovenian")]
Slovenian,
#[cfg(feature = "spanish")]
Spanish,
#[cfg(feature = "swedish")]
Swedish,
#[cfg(feature = "tamil")]
Tamil,
#[cfg(feature = "telugu")]
Telugu,
#[cfg(feature = "turkish")]
Turkish,
#[cfg(feature = "turkmen")]
Turkmen,
#[cfg(feature = "ukrainian")]
Ukrainian,
}
impl Lang {
pub fn from_iso(code: [u8; 2]) -> Option<Self> {
match &code {
#[cfg(feature = "afrikaans")]
b"af" => Some(Self::Afrikaans),
#[cfg(feature = "albanian")]
b"sq" => Some(Self::Albanian),
#[cfg(feature = "assamese")]
b"as" => Some(Self::Assamese),
#[cfg(feature = "belarusian")]
b"be" => Some(Self::Belarusian),
#[cfg(feature = "bengali")]
b"bn" => Some(Self::Bengali),
#[cfg(feature = "bulgarian")]
b"bg" => Some(Self::Bulgarian),
#[cfg(feature = "catalan")]
b"ca" => Some(Self::Catalan),
#[cfg(feature = "croatian")]
b"hr" => Some(Self::Croatian),
#[cfg(feature = "czech")]
b"cs" => Some(Self::Czech),
#[cfg(feature = "danish")]
b"da" => Some(Self::Danish),
#[cfg(feature = "dutch")]
b"nl" => Some(Self::Dutch),
#[cfg(feature = "english")]
b"en" => Some(Self::English),
#[cfg(feature = "estonian")]
b"et" => Some(Self::Estonian),
#[cfg(feature = "finnish")]
b"fi" => Some(Self::Finnish),
#[cfg(feature = "french")]
b"fr" => Some(Self::French),
#[cfg(feature = "galician")]
b"gl" => Some(Self::Galician),
#[cfg(feature = "georgian")]
b"ka" => Some(Self::Georgian),
#[cfg(feature = "german")]
b"de" => Some(Self::German),
#[cfg(feature = "greek")]
b"el" => Some(Self::Greek),
#[cfg(feature = "gujarati")]
b"gu" => Some(Self::Gujarati),
#[cfg(feature = "hindi")]
b"hi" => Some(Self::Hindi),
#[cfg(feature = "hungarian")]
b"hu" => Some(Self::Hungarian),
#[cfg(feature = "icelandic")]
b"is" => Some(Self::Icelandic),
#[cfg(feature = "italian")]
b"it" => Some(Self::Italian),
#[cfg(feature = "kannada")]
b"kn" => Some(Self::Kannada),
#[cfg(feature = "kurmanji")]
b"ku" => Some(Self::Kurmanji),
#[cfg(feature = "latin")]
b"la" => Some(Self::Latin),
#[cfg(feature = "lithuanian")]
b"lt" => Some(Self::Lithuanian),
#[cfg(feature = "malayalam")]
b"ml" => Some(Self::Malayalam),
#[cfg(feature = "marathi")]
b"mr" => Some(Self::Marathi),
#[cfg(feature = "mongolian")]
b"mn" => Some(Self::Mongolian),
#[cfg(feature = "norwegian")]
b"no" => Some(Self::Norwegian),
#[cfg(feature = "norwegian")]
b"nb" => Some(Self::Norwegian),
#[cfg(feature = "norwegian")]
b"nn" => Some(Self::Norwegian),
#[cfg(feature = "oriya")]
b"or" => Some(Self::Oriya),
#[cfg(feature = "panjabi")]
b"pa" => Some(Self::Panjabi),
#[cfg(feature = "polish")]
b"pl" => Some(Self::Polish),
#[cfg(feature = "portuguese")]
b"pt" => Some(Self::Portuguese),
#[cfg(feature = "russian")]
b"ru" => Some(Self::Russian),
#[cfg(feature = "sanskrit")]
b"sa" => Some(Self::Sanskrit),
#[cfg(feature = "serbian")]
b"sr" => Some(Self::Serbian),
#[cfg(feature = "slovak")]
b"sk" => Some(Self::Slovak),
#[cfg(feature = "slovenian")]
b"sl" => Some(Self::Slovenian),
#[cfg(feature = "spanish")]
b"es" => Some(Self::Spanish),
#[cfg(feature = "swedish")]
b"sv" => Some(Self::Swedish),
#[cfg(feature = "tamil")]
b"ta" => Some(Self::Tamil),
#[cfg(feature = "telugu")]
b"te" => Some(Self::Telugu),
#[cfg(feature = "turkish")]
b"tr" => Some(Self::Turkish),
#[cfg(feature = "turkmen")]
b"tk" => Some(Self::Turkmen),
#[cfg(feature = "ukrainian")]
b"uk" => Some(Self::Ukrainian),
_ => None,
}
}
pub fn bounds(self) -> (usize, usize) {
match self {
#[cfg(feature = "afrikaans")]
Self::Afrikaans => (1, 2),
#[cfg(feature = "albanian")]
Self::Albanian => (2, 2),
#[cfg(feature = "assamese")]
Self::Assamese => (2, 2),
#[cfg(feature = "belarusian")]
Self::Belarusian => (2, 2),
#[cfg(feature = "bengali")]
Self::Bengali => (2, 2),
#[cfg(feature = "bulgarian")]
Self::Bulgarian => (2, 2),
#[cfg(feature = "catalan")]
Self::Catalan => (2, 2),
#[cfg(feature = "croatian")]
Self::Croatian => (2, 2),
#[cfg(feature = "czech")]
Self::Czech => (2, 2),
#[cfg(feature = "danish")]
Self::Danish => (2, 2),
#[cfg(feature = "dutch")]
Self::Dutch => (2, 2),
#[cfg(feature = "english")]
Self::English => (2, 3),
#[cfg(feature = "estonian")]
Self::Estonian => (2, 3),
#[cfg(feature = "finnish")]
Self::Finnish => (2, 2),
#[cfg(feature = "french")]
Self::French => (2, 2),
#[cfg(feature = "galician")]
Self::Galician => (2, 2),
#[cfg(feature = "georgian")]
Self::Georgian => (1, 2),
#[cfg(feature = "german")]
Self::German => (2, 2),
#[cfg(feature = "greek")]
Self::Greek => (1, 1),
#[cfg(feature = "gujarati")]
Self::Gujarati => (2, 2),
#[cfg(feature = "hindi")]
Self::Hindi => (2, 2),
#[cfg(feature = "hungarian")]
Self::Hungarian => (2, 2),
#[cfg(feature = "icelandic")]
Self::Icelandic => (2, 2),
#[cfg(feature = "italian")]
Self::Italian => (2, 2),
#[cfg(feature = "kannada")]
Self::Kannada => (2, 2),
#[cfg(feature = "kurmanji")]
Self::Kurmanji => (2, 2),
#[cfg(feature = "latin")]
Self::Latin => (2, 2),
#[cfg(feature = "lithuanian")]
Self::Lithuanian => (2, 2),
#[cfg(feature = "malayalam")]
Self::Malayalam => (2, 2),
#[cfg(feature = "marathi")]
Self::Marathi => (2, 2),
#[cfg(feature = "mongolian")]
Self::Mongolian => (2, 2),
#[cfg(feature = "norwegian")]
Self::Norwegian => (2, 2),
#[cfg(feature = "oriya")]
Self::Oriya => (2, 2),
#[cfg(feature = "panjabi")]
Self::Panjabi => (2, 2),
#[cfg(feature = "polish")]
Self::Polish => (2, 2),
#[cfg(feature = "portuguese")]
Self::Portuguese => (2, 3),
#[cfg(feature = "russian")]
Self::Russian => (2, 2),
#[cfg(feature = "sanskrit")]
Self::Sanskrit => (2, 2),
#[cfg(feature = "serbian")]
Self::Serbian => (2, 2),
#[cfg(feature = "slovak")]
Self::Slovak => (2, 3),
#[cfg(feature = "slovenian")]
Self::Slovenian => (2, 2),
#[cfg(feature = "spanish")]
Self::Spanish => (2, 2),
#[cfg(feature = "swedish")]
Self::Swedish => (2, 2),
#[cfg(feature = "tamil")]
Self::Tamil => (2, 2),
#[cfg(feature = "telugu")]
Self::Telugu => (2, 2),
#[cfg(feature = "turkish")]
Self::Turkish => (2, 2),
#[cfg(feature = "turkmen")]
Self::Turkmen => (2, 2),
#[cfg(feature = "ukrainian")]
Self::Ukrainian => (2, 2),
}
}
pub fn hyphenation_character(self) -> Option<char> {
match self {
#[cfg(feature = "assamese")]
Self::Assamese => None,
#[cfg(feature = "bengali")]
Self::Bengali => None,
#[cfg(feature = "gujarati")]
Self::Gujarati => None,
#[cfg(feature = "hindi")]
Self::Hindi => None,
#[cfg(feature = "kannada")]
Self::Kannada => None,
#[cfg(feature = "malayalam")]
Self::Malayalam => None,
#[cfg(feature = "marathi")]
Self::Marathi => None,
#[cfg(feature = "oriya")]
Self::Oriya => None,
#[cfg(feature = "panjabi")]
Self::Panjabi => None,
#[cfg(feature = "sanskrit")]
Self::Sanskrit => None,
#[cfg(feature = "tamil")]
Self::Tamil => None,
#[cfg(feature = "telugu")]
Self::Telugu => None,
_ => Some('\u{ad}'),
}
}
fn root(self) -> State<'static> {
match self {
#[cfg(feature = "afrikaans")]
Self::Afrikaans => State::root(include_bytes!("../tries/af.bin")),
#[cfg(feature = "albanian")]
Self::Albanian => State::root(include_bytes!("../tries/sq.bin")),
#[cfg(feature = "assamese")]
Self::Assamese => State::root(include_bytes!("../tries/as.bin")),
#[cfg(feature = "belarusian")]
Self::Belarusian => State::root(include_bytes!("../tries/be.bin")),
#[cfg(feature = "bengali")]
Self::Bengali => State::root(include_bytes!("../tries/bn.bin")),
#[cfg(feature = "bulgarian")]
Self::Bulgarian => State::root(include_bytes!("../tries/bg.bin")),
#[cfg(feature = "catalan")]
Self::Catalan => State::root(include_bytes!("../tries/ca.bin")),
#[cfg(feature = "croatian")]
Self::Croatian => State::root(include_bytes!("../tries/hr.bin")),
#[cfg(feature = "czech")]
Self::Czech => State::root(include_bytes!("../tries/cs.bin")),
#[cfg(feature = "danish")]
Self::Danish => State::root(include_bytes!("../tries/da.bin")),
#[cfg(feature = "dutch")]
Self::Dutch => State::root(include_bytes!("../tries/nl.bin")),
#[cfg(feature = "english")]
Self::English => State::root(include_bytes!("../tries/en.bin")),
#[cfg(feature = "estonian")]
Self::Estonian => State::root(include_bytes!("../tries/et.bin")),
#[cfg(feature = "finnish")]
Self::Finnish => State::root(include_bytes!("../tries/fi.bin")),
#[cfg(feature = "french")]
Self::French => State::root(include_bytes!("../tries/fr.bin")),
#[cfg(feature = "galician")]
Self::Galician => State::root(include_bytes!("../tries/gl.bin")),
#[cfg(feature = "georgian")]
Self::Georgian => State::root(include_bytes!("../tries/ka.bin")),
#[cfg(feature = "german")]
Self::German => State::root(include_bytes!("../tries/de.bin")),
#[cfg(feature = "greek")]
Self::Greek => State::root(include_bytes!("../tries/el.bin")),
#[cfg(feature = "gujarati")]
Self::Gujarati => State::root(include_bytes!("../tries/gu.bin")),
#[cfg(feature = "hindi")]
Self::Hindi => State::root(include_bytes!("../tries/hi.bin")),
#[cfg(feature = "hungarian")]
Self::Hungarian => State::root(include_bytes!("../tries/hu.bin")),
#[cfg(feature = "icelandic")]
Self::Icelandic => State::root(include_bytes!("../tries/is.bin")),
#[cfg(feature = "italian")]
Self::Italian => State::root(include_bytes!("../tries/it.bin")),
#[cfg(feature = "kannada")]
Self::Kannada => State::root(include_bytes!("../tries/kn.bin")),
#[cfg(feature = "kurmanji")]
Self::Kurmanji => State::root(include_bytes!("../tries/ku.bin")),
#[cfg(feature = "latin")]
Self::Latin => State::root(include_bytes!("../tries/la.bin")),
#[cfg(feature = "lithuanian")]
Self::Lithuanian => State::root(include_bytes!("../tries/lt.bin")),
#[cfg(feature = "malayalam")]
Self::Malayalam => State::root(include_bytes!("../tries/ml.bin")),
#[cfg(feature = "marathi")]
Self::Marathi => State::root(include_bytes!("../tries/mr.bin")),
#[cfg(feature = "mongolian")]
Self::Mongolian => State::root(include_bytes!("../tries/mn.bin")),
#[cfg(feature = "norwegian")]
Self::Norwegian => State::root(include_bytes!("../tries/no.bin")),
#[cfg(feature = "oriya")]
Self::Oriya => State::root(include_bytes!("../tries/or.bin")),
#[cfg(feature = "panjabi")]
Self::Panjabi => State::root(include_bytes!("../tries/pa.bin")),
#[cfg(feature = "polish")]
Self::Polish => State::root(include_bytes!("../tries/pl.bin")),
#[cfg(feature = "portuguese")]
Self::Portuguese => State::root(include_bytes!("../tries/pt.bin")),
#[cfg(feature = "russian")]
Self::Russian => State::root(include_bytes!("../tries/ru.bin")),
#[cfg(feature = "sanskrit")]
Self::Sanskrit => State::root(include_bytes!("../tries/sa.bin")),
#[cfg(feature = "serbian")]
Self::Serbian => State::root(include_bytes!("../tries/sr.bin")),
#[cfg(feature = "slovak")]
Self::Slovak => State::root(include_bytes!("../tries/sk.bin")),
#[cfg(feature = "slovenian")]
Self::Slovenian => State::root(include_bytes!("../tries/sl.bin")),
#[cfg(feature = "spanish")]
Self::Spanish => State::root(include_bytes!("../tries/es.bin")),
#[cfg(feature = "swedish")]
Self::Swedish => State::root(include_bytes!("../tries/sv.bin")),
#[cfg(feature = "tamil")]
Self::Tamil => State::root(include_bytes!("../tries/ta.bin")),
#[cfg(feature = "telugu")]
Self::Telugu => State::root(include_bytes!("../tries/te.bin")),
#[cfg(feature = "turkish")]
Self::Turkish => State::root(include_bytes!("../tries/tr.bin")),
#[cfg(feature = "turkmen")]
Self::Turkmen => State::root(include_bytes!("../tries/tk.bin")),
#[cfg(feature = "ukrainian")]
Self::Ukrainian => State::root(include_bytes!("../tries/uk.bin")),
}
}
}