From 7e5e7f1b1ea332458f1bf1234077697dc932c015 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 9 Aug 2024 10:44:33 +0800 Subject: [PATCH 1/4] Release v3.1.0 --- Cargo.toml | 2 +- crates/cli/Cargo.toml | 2 +- crates/extract/Cargo.toml | 2 +- crates/macro/Cargo.toml | 2 +- crates/macro/src/tr.rs | 5 +++-- crates/support/Cargo.toml | 2 +- crates/support/src/lib.rs | 5 ++--- tests/integration_tests.rs | 4 +--- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index da04644..120113c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ license = "MIT" name = "rust-i18n" readme = "README.md" repository = "https://github.com/longbridgeapp/rust-i18n" -version = "3.0.2-alpha.0" +version = "3.1.0" [dependencies] once_cell = "1.10.0" diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index d397d72..168b647 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -5,7 +5,7 @@ license = "MIT" name = "rust-i18n-cli" readme = "../../README.md" repository = "https://github.com/longbridgeapp/rust-i18n" -version = "3.0.0" +version = "3.1.0" [dependencies] anyhow = "1" diff --git a/crates/extract/Cargo.toml b/crates/extract/Cargo.toml index f4522cd..867fb52 100644 --- a/crates/extract/Cargo.toml +++ b/crates/extract/Cargo.toml @@ -5,7 +5,7 @@ license = "MIT" name = "rust-i18n-extract" readme = "../../README.md" repository = "https://github.com/longbridgeapp/rust-i18n" -version = "3.0.0" +version = "3.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/macro/Cargo.toml b/crates/macro/Cargo.toml index 2661b3e..2b4868e 100644 --- a/crates/macro/Cargo.toml +++ b/crates/macro/Cargo.toml @@ -5,7 +5,7 @@ license = "MIT" name = "rust-i18n-macro" readme = "../../README.md" repository = "https://github.com/longbridgeapp/rust-i18n" -version = "3.0.0" +version = "3.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/macro/src/tr.rs b/crates/macro/src/tr.rs index 77b479a..33bd15c 100644 --- a/crates/macro/src/tr.rs +++ b/crates/macro/src/tr.rs @@ -223,8 +223,9 @@ impl syn::parse::Parse for Arguments { #[derive(Default)] pub struct Messsage { - pub key: proc_macro2::TokenStream, - pub val: Value, + #[allow(dead_code)] + key: proc_macro2::TokenStream, + val: Value, } impl Messsage { diff --git a/crates/support/Cargo.toml b/crates/support/Cargo.toml index a556254..d2ab753 100644 --- a/crates/support/Cargo.toml +++ b/crates/support/Cargo.toml @@ -5,7 +5,7 @@ license = "MIT" name = "rust-i18n-support" readme = "../../README.md" repository = "https://github.com/longbridgeapp/rust-i18n" -version = "3.0.1" +version = "3.1.0" [dependencies] arc-swap = "1.6.0" diff --git a/crates/support/src/lib.rs b/crates/support/src/lib.rs index 4e300bc..24a4ecc 100644 --- a/crates/support/src/lib.rs +++ b/crates/support/src/lib.rs @@ -199,7 +199,7 @@ fn parse_file_v2(key_prefix: &str, data: &serde_json::Value) -> Option Option), iter them and convert them and insert into trs - let key = format_keys(&[&key_prefix, &key]); + let key = format_keys(&[key_prefix, key]); if let Some(sub_trs) = parse_file_v2(&key, value) { - // println!("--------------- sub_trs:\n{:?}", sub_trs); // Merge the sub_trs into trs for (locale, sub_value) in sub_trs { trs.entry(locale) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 1981ef8..9e88084 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -101,9 +101,7 @@ mod tests { #[test] fn test_load() { - assert!(load_locales("./tests/locales", |_| false) - .get("en") - .is_some()); + assert!(load_locales("./tests/locales", |_| false).contains_key("en")); } #[test] From b58513111a8a22efb0159e39e78424ed0ff78257 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 9 Aug 2024 10:53:39 +0800 Subject: [PATCH 2/4] Remove crate keywords --- Cargo.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 120113c..77c6f84 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,13 +8,9 @@ exclude = ["crates", "tests"] keywords = [ "gettext", "i18n", - "l10n", - "intl", "internationalization", "localization", - "tr", "translation", - "yml", ] license = "MIT" name = "rust-i18n" From 1d791aae3f58b464c58b10ca3028649cbbb287f0 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 9 Aug 2024 11:38:48 +0800 Subject: [PATCH 3/4] Update to use serde_yml --- Cargo.toml | 8 ++++---- README.md | 2 +- crates/extract/Cargo.toml | 2 +- crates/extract/src/generator.rs | 2 +- crates/macro/Cargo.toml | 2 +- crates/support/Cargo.toml | 2 +- crates/support/src/lib.rs | 8 ++++---- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 77c6f84..8436bb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,19 +16,19 @@ license = "MIT" name = "rust-i18n" readme = "README.md" repository = "https://github.com/longbridgeapp/rust-i18n" -version = "3.1.0" +version = "3.1.1" [dependencies] once_cell = "1.10.0" -rust-i18n-support = { path = "./crates/support", version = "3.0.1" } -rust-i18n-macro = { path = "./crates/macro", version = "3.0.0" } +rust-i18n-support = { path = "./crates/support", version = "3.1.0" } +rust-i18n-macro = { path = "./crates/macro", version = "3.1.0" } smallvec = "1.12.0" [dev-dependencies] foo = { path = "examples/foo" } criterion = "0.5" lazy_static = "1" -serde_yaml = "0.8" +serde_yml = "0.0.11" [build-dependencies] globwalk = "0.8.1" diff --git a/README.md b/README.md index 1b94e8e..8c619d4 100644 --- a/README.md +++ b/README.md @@ -264,7 +264,7 @@ impl RemoteI18n { fn new() -> Self { // fetch translations from remote URL let response = reqwest::blocking::get("https://your-host.com/assets/locales.yml").unwrap(); - let trs = serde_yaml::from_str::>>(&response.text().unwrap()).unwrap(); + let trs = serde_yml::from_str::>>(&response.text().unwrap()).unwrap(); return Self { trs diff --git a/crates/extract/Cargo.toml b/crates/extract/Cargo.toml index 867fb52..c59931c 100644 --- a/crates/extract/Cargo.toml +++ b/crates/extract/Cargo.toml @@ -18,7 +18,7 @@ regex = "1" rust-i18n-support = { path = "../support", version = "3.0.0" } serde = "1" serde_json = "1" -serde_yaml = "0.8" +serde_yml = "0.0.11" syn = { version = "2.0.18", features = ["full"] } toml = "0.7.4" diff --git a/crates/extract/src/generator.rs b/crates/extract/src/generator.rs index b378708..5cd308e 100644 --- a/crates/extract/src/generator.rs +++ b/crates/extract/src/generator.rs @@ -50,7 +50,7 @@ fn convert_text(trs: &Translations, format: &str) -> String { match format { "json" => serde_json::to_string_pretty(&value).unwrap(), "yaml" | "yml" => { - let text = serde_yaml::to_string(&value).unwrap(); + let text = serde_yml::to_string(&value).unwrap(); // Remove leading `---` text.trim_start_matches("---").trim_start().to_string() } diff --git a/crates/macro/Cargo.toml b/crates/macro/Cargo.toml index 2b4868e..586dac9 100644 --- a/crates/macro/Cargo.toml +++ b/crates/macro/Cargo.toml @@ -17,7 +17,7 @@ quote = "1.0.2" rust-i18n-support = { path = "../support", version = "3.0.0" } serde = "1" serde_json = "1" -serde_yaml = "0.8" +serde_yml = "0.0.11" syn = { version = "2.0.18", features = ["full", "extra-traits"] } [dev-dependencies] diff --git a/crates/support/Cargo.toml b/crates/support/Cargo.toml index d2ab753..9e93f5d 100644 --- a/crates/support/Cargo.toml +++ b/crates/support/Cargo.toml @@ -16,7 +16,7 @@ once_cell = "1.10.0" proc-macro2 = "1.0" serde = { version = "1", features = ["derive"] } serde_json = "1" -serde_yaml = "0.8" +serde_yml = "0.0.11" siphasher = "1.0" toml = "0.7.4" normpath = "1.1.1" diff --git a/crates/support/src/lib.rs b/crates/support/src/lib.rs index 24a4ecc..3c8ccfe 100644 --- a/crates/support/src/lib.rs +++ b/crates/support/src/lib.rs @@ -126,7 +126,7 @@ pub fn load_locales bool>( // Parse Translations from file to support multiple formats fn parse_file(content: &str, ext: &str, locale: &str) -> Result { let result = match ext { - "yml" | "yaml" => serde_yaml::from_str::(content) + "yml" | "yaml" => serde_yml::from_str::(content) .map_err(|err| format!("Invalid YAML format, {}", err)), "json" => serde_json::from_str::(content) .map_err(|err| format!("Invalid JSON format, {}", err)), @@ -355,14 +355,14 @@ mod tests { #[test] fn test_get_version() { - let json = serde_yaml::from_str::("_version: 2").unwrap(); + let json = serde_yml::from_str::("_version: 2").unwrap(); assert_eq!(super::get_version(&json), 2); - let json = serde_yaml::from_str::("_version: 1").unwrap(); + let json = serde_yml::from_str::("_version: 1").unwrap(); assert_eq!(super::get_version(&json), 1); // Default fallback to 1 - let json = serde_yaml::from_str::("foo: Foo").unwrap(); + let json = serde_yml::from_str::("foo: Foo").unwrap(); assert_eq!(super::get_version(&json), 1); } From 4d7c603602a5241c1933a621d8e5d03628af41cf Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 9 Aug 2024 11:41:31 +0800 Subject: [PATCH 4/4] Update versions --- Cargo.toml | 4 ++-- crates/cli/Cargo.toml | 2 +- crates/extract/Cargo.toml | 2 +- crates/macro/Cargo.toml | 2 +- crates/support/Cargo.toml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8436bb7..14d84f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,8 +20,8 @@ version = "3.1.1" [dependencies] once_cell = "1.10.0" -rust-i18n-support = { path = "./crates/support", version = "3.1.0" } -rust-i18n-macro = { path = "./crates/macro", version = "3.1.0" } +rust-i18n-support = { path = "./crates/support", version = "3.1.1" } +rust-i18n-macro = { path = "./crates/macro", version = "3.1.1" } smallvec = "1.12.0" [dev-dependencies] diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 168b647..8142f64 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -5,7 +5,7 @@ license = "MIT" name = "rust-i18n-cli" readme = "../../README.md" repository = "https://github.com/longbridgeapp/rust-i18n" -version = "3.1.0" +version = "3.1.1" [dependencies] anyhow = "1" diff --git a/crates/extract/Cargo.toml b/crates/extract/Cargo.toml index c59931c..afec66e 100644 --- a/crates/extract/Cargo.toml +++ b/crates/extract/Cargo.toml @@ -5,7 +5,7 @@ license = "MIT" name = "rust-i18n-extract" readme = "../../README.md" repository = "https://github.com/longbridgeapp/rust-i18n" -version = "3.1.0" +version = "3.1.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/macro/Cargo.toml b/crates/macro/Cargo.toml index 586dac9..b246bdf 100644 --- a/crates/macro/Cargo.toml +++ b/crates/macro/Cargo.toml @@ -5,7 +5,7 @@ license = "MIT" name = "rust-i18n-macro" readme = "../../README.md" repository = "https://github.com/longbridgeapp/rust-i18n" -version = "3.1.0" +version = "3.1.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/support/Cargo.toml b/crates/support/Cargo.toml index 9e93f5d..dadf00f 100644 --- a/crates/support/Cargo.toml +++ b/crates/support/Cargo.toml @@ -5,7 +5,7 @@ license = "MIT" name = "rust-i18n-support" readme = "../../README.md" repository = "https://github.com/longbridgeapp/rust-i18n" -version = "3.1.0" +version = "3.1.1" [dependencies] arc-swap = "1.6.0"