tauri-plugin-sys-locale 0.1.2

Tauri plugin to read the operating system's current locale/language
use serde::{Serialize, Serializer};

#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("could not determine the system locale")]
    NotFound,
}

// Tauri commands must be able to serialize errors so they arrive
// as a JS promise rejection.
impl Serialize for Error {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: Serializer,
    {
        serializer.serialize_str(self.to_string().as_ref())
    }
}

pub type Result<T> = std::result::Result<T, Error>;