use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
pub enum I18nError {
#[error("invalid locale: {0}")]
InvalidLocale(String),
#[error("translation key not found: {key} (locale: {locale})")]
TranslationNotFound { key: String, locale: String },
#[cfg(feature = "toml-backend")]
#[error("failed to parse TOML for locale '{locale}': {source}")]
TomlParseError {
locale: String,
#[source]
source: toml::de::Error,
},
#[cfg(feature = "json-backend")]
#[error("failed to parse JSON for locale '{locale}': {source}")]
JsonParseError {
locale: String,
#[source]
source: serde_json::Error,
},
#[cfg(feature = "yaml-backend")]
#[error("failed to parse YAML for locale '{locale}': {source}")]
YamlParseError {
locale: String,
#[source]
source: serde_yaml::Error,
},
#[error("database error: {0}")]
DatabaseError(String),
#[error("failed to read translation file: {path}")]
IoError {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("interpolation error for key '{key}': missing variable '{var}'")]
InterpolationError { key: String, var: String },
#[error("i18n configuration error: {0}")]
ConfigError(String),
#[error("no i18n backend configured")]
NoBackend,
#[error("builder error: {0}")]
BuilderError(String),
#[error("file watcher error: {0}")]
WatchError(String),
}