lang-id 0.0.20

Const lang-ids and maps are provided, mainly for i18n and l10n.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::{LangID, RawID};

/// `s.trim()` if `is_not_empty()` => `.parse::<LangID>().ok()`
pub fn try_parse_to_langid(s: &str) -> Option<LangID> {
  match s.trim() {
    "" => None,
    x => x.parse().ok(),
  }
}

/// en: (en-Latn-US) English, Latin, United States
pub const fn lang_id_en() -> LangID {
  RawID::new(28261, None, None).into_lang_id()
}