zakat_i18n/lib.rs
1//! zakat-i18n - Internationalization and Localization for Zakat Library
2//!
3//! This crate provides translation and currency formatting capabilities
4//! for the Zakat calculation library using fluent-rs and ICU4X.
5//!
6//! ## Features
7//!
8//! - Multi-locale support (English, Indonesian, Arabic)
9//! - Currency formatting using ICU4X
10//! - Fluent translation bundles for error messages and UI strings
11
12mod i18n;
13
14pub use i18n::*;
15
16/// Trait for loading translation resources asynchronously.
17///
18/// This allows decoupling the translation files from the binary, enabling
19/// lazy loading in environments like WASM (fetching from URL) or mobile (fetching from disk/network).
20#[cfg(not(target_arch = "wasm32"))]
21pub trait ResourceLoader: Send + Sync + 'static {
22 /// Load a Fluent resource string for the given locale.
23 fn load_resource(&self, locale: &str) -> std::pin::Pin<Box<dyn std::future::Future<Output = Result<String, String>> + Send>>;
24}
25
26#[cfg(target_arch = "wasm32")]
27pub trait ResourceLoader: 'static {
28 /// Load a Fluent resource string for the given locale.
29 fn load_resource(&self, locale: &str) -> std::pin::Pin<Box<dyn std::future::Future<Output = Result<String, String>>>>;
30}