use crate::prelude::*;
use std::{
fmt::Display,
ops::{Deref, Range},
slice::Iter,
str::FromStr,
};
static LANG_DATA: &[u8] = include_bytes!("./ftl.bin"); static ALL_LANGS: [L10n; 1] = [L10n::Placeholder];
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum L10n {
Placeholder, }
impl Default for L10n {
fn default() -> Self {
Self::Placeholder }
}
impl FromStr for L10n {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"placeholder" => Ok(Self::Placeholder), _ => Err(format!("Unknown language: {}", s)),
}
}
}
impl Deref for L10n {
type Target = str;
fn deref(&self) -> &Self::Target {
match self {
Self::Placeholder => "placeholder", }
}
}
impl AsRef<str> for L10n {
fn as_ref(&self) -> &str {
self
}
}
impl Display for L10n {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.deref())
}
}
impl L10n {
pub fn iter() -> Iter<'static, L10n> {
ALL_LANGS.iter()
}
}
pub struct L10nLanguage(L10nBundle);
impl L10nLanguage {
pub fn new(lang: impl AsRef<str>, bytes: &[u8]) -> Result<Self, String> {
Ok(Self(L10nBundle::new(lang, bytes)?)) }
}