diff --git a/Cargo.toml b/Cargo.toml index 62b2fc4..961b4de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ version = "0.5.3-alpha.0" anyhow = {version = "1", optional = true} clap = {version = "2.32", optional = true} itertools = {version = "0.10.3", optional = true} -lazy_static = "1.4.0" +once_cell = "1.10.0" quote = {version = "1", optional = true} rust-i18n-extract = {path = "./crates/extract", version = "0.3", optional = true} rust-i18n-macro = {path = "./crates/macro", version = "0.3"} diff --git a/README.md b/README.md index f75e794..3f63fb3 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Add crate dependencies in your Cargo.toml and setup I18n config: ```toml [dependencies] -lazy_static = "1.4.0" +once_cell = "1.10.0" rust-i18n = "0" [package.metadata.i18n] diff --git a/crates/macro/Cargo.toml b/crates/macro/Cargo.toml index e87e2fc..38bbde9 100644 --- a/crates/macro/Cargo.toml +++ b/crates/macro/Cargo.toml @@ -11,7 +11,7 @@ version = "0.3.0" [dependencies] glob = "0.3" -lazy_static = "1.4.0" +once_cell = "1.10.0" proc-macro2 = "1.0" quote = "1.0.2" rust-i18n-support = {path = "../support", version = "0.3"} diff --git a/crates/macro/src/lib.rs b/crates/macro/src/lib.rs index b54e2b9..92e630c 100644 --- a/crates/macro/src/lib.rs +++ b/crates/macro/src/lib.rs @@ -59,12 +59,10 @@ fn generate_code(translations: HashMap) -> proc_macro2::TokenStr // result quote! { - lazy_static::lazy_static! { - static ref LOCALES: std::collections::HashMap<&'static str, &'static str> = rust_i18n::map! [ - #(#locales)* - "" => "" - ]; - } + static LOCALES: once_cell::sync::Lazy> = once_cell::sync::Lazy::new(|| rust_i18n::map! [ + #(#locales)* + "" => "" + ]); pub fn translate(locale: &str, key: &str) -> String { diff --git a/crates/support/Cargo.toml b/crates/support/Cargo.toml index 0fe5acf..6ae4f8a 100644 --- a/crates/support/Cargo.toml +++ b/crates/support/Cargo.toml @@ -9,7 +9,7 @@ version = "0.3.0" [dependencies] glob = "0.3" -lazy_static = "1.4.0" +once_cell = "1.10.0" proc-macro2 = "1.0" serde = "1" serde_json = "1" diff --git a/examples/foo/Cargo.toml b/examples/foo/Cargo.toml index edecb22..273b86e 100644 --- a/examples/foo/Cargo.toml +++ b/examples/foo/Cargo.toml @@ -7,7 +7,7 @@ version = "0.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -lazy_static = "1.4.0" +once_cell = "1.10.0" rust-i18n = {path = "../../../rust-i18n"} [package.metadata.i18n] diff --git a/src/lib.rs b/src/lib.rs index 70e2d96..73c9865 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ Add crate dependencies in your Cargo.toml: ```toml [dependencies] -lazy_static = "1.4.0" +once_cell = "1.10.0" rust-i18n = "0" ``` @@ -67,13 +67,12 @@ rust_i18n::locale(); ``` */ // include!(concat!(env!("OUT_DIR"), "/i18n.rs")); +use once_cell::sync::Lazy; use std::sync::Mutex; pub use rust_i18n_macro::i18n; -lazy_static::lazy_static! { - static ref CURRENT_LOCALE: Mutex = Mutex::new(String::from("en")); -} +static CURRENT_LOCALE: Lazy> = Lazy::new(|| Mutex::new(String::from("en"))); pub fn set_locale(locale: &str) { let mut current_locale = CURRENT_LOCALE.lock().unwrap();