Skip to content

Commit 0e67913

Browse files
authored
Update to use serde_yml (#86)
1 parent b585131 commit 0e67913

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ license = "MIT"
1616
name = "rust-i18n"
1717
readme = "README.md"
1818
repository = "https://github.com/longbridgeapp/rust-i18n"
19-
version = "3.1.0"
19+
version = "3.1.1"
2020

2121
[dependencies]
2222
once_cell = "1.10.0"
23-
rust-i18n-support = { path = "./crates/support", version = "3.0.1" }
24-
rust-i18n-macro = { path = "./crates/macro", version = "3.0.0" }
23+
rust-i18n-support = { path = "./crates/support", version = "3.1.1" }
24+
rust-i18n-macro = { path = "./crates/macro", version = "3.1.1" }
2525
smallvec = "1.12.0"
2626

2727
[dev-dependencies]
2828
foo = { path = "examples/foo" }
2929
criterion = "0.5"
3030
lazy_static = "1"
31-
serde_yaml = "0.8"
31+
serde_yml = "0.0.11"
3232

3333
[build-dependencies]
3434
globwalk = "0.8.1"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ impl RemoteI18n {
264264
fn new() -> Self {
265265
// fetch translations from remote URL
266266
let response = reqwest::blocking::get("https://your-host.com/assets/locales.yml").unwrap();
267-
let trs = serde_yaml::from_str::<HashMap<String, HashMap<String, String>>>(&response.text().unwrap()).unwrap();
267+
let trs = serde_yml::from_str::<HashMap<String, HashMap<String, String>>>(&response.text().unwrap()).unwrap();
268268
269269
return Self {
270270
trs

crates/cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license = "MIT"
55
name = "rust-i18n-cli"
66
readme = "../../README.md"
77
repository = "https://github.com/longbridgeapp/rust-i18n"
8-
version = "3.1.0"
8+
version = "3.1.1"
99

1010
[dependencies]
1111
anyhow = "1"

crates/extract/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license = "MIT"
55
name = "rust-i18n-extract"
66
readme = "../../README.md"
77
repository = "https://github.com/longbridgeapp/rust-i18n"
8-
version = "3.1.0"
8+
version = "3.1.1"
99

1010
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1111

@@ -18,7 +18,7 @@ regex = "1"
1818
rust-i18n-support = { path = "../support", version = "3.0.0" }
1919
serde = "1"
2020
serde_json = "1"
21-
serde_yaml = "0.8"
21+
serde_yml = "0.0.11"
2222
syn = { version = "2.0.18", features = ["full"] }
2323
toml = "0.7.4"
2424

crates/extract/src/generator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn convert_text(trs: &Translations, format: &str) -> String {
5050
match format {
5151
"json" => serde_json::to_string_pretty(&value).unwrap(),
5252
"yaml" | "yml" => {
53-
let text = serde_yaml::to_string(&value).unwrap();
53+
let text = serde_yml::to_string(&value).unwrap();
5454
// Remove leading `---`
5555
text.trim_start_matches("---").trim_start().to_string()
5656
}

crates/macro/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license = "MIT"
55
name = "rust-i18n-macro"
66
readme = "../../README.md"
77
repository = "https://github.com/longbridgeapp/rust-i18n"
8-
version = "3.1.0"
8+
version = "3.1.1"
99

1010
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1111

@@ -17,7 +17,7 @@ quote = "1.0.2"
1717
rust-i18n-support = { path = "../support", version = "3.0.0" }
1818
serde = "1"
1919
serde_json = "1"
20-
serde_yaml = "0.8"
20+
serde_yml = "0.0.11"
2121
syn = { version = "2.0.18", features = ["full", "extra-traits"] }
2222

2323
[dev-dependencies]

crates/support/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license = "MIT"
55
name = "rust-i18n-support"
66
readme = "../../README.md"
77
repository = "https://github.com/longbridgeapp/rust-i18n"
8-
version = "3.1.0"
8+
version = "3.1.1"
99

1010
[dependencies]
1111
arc-swap = "1.6.0"
@@ -16,7 +16,7 @@ once_cell = "1.10.0"
1616
proc-macro2 = "1.0"
1717
serde = { version = "1", features = ["derive"] }
1818
serde_json = "1"
19-
serde_yaml = "0.8"
19+
serde_yml = "0.0.11"
2020
siphasher = "1.0"
2121
toml = "0.7.4"
2222
normpath = "1.1.1"

crates/support/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub fn load_locales<F: Fn(&str) -> bool>(
126126
// Parse Translations from file to support multiple formats
127127
fn parse_file(content: &str, ext: &str, locale: &str) -> Result<Translations, String> {
128128
let result = match ext {
129-
"yml" | "yaml" => serde_yaml::from_str::<serde_json::Value>(content)
129+
"yml" | "yaml" => serde_yml::from_str::<serde_json::Value>(content)
130130
.map_err(|err| format!("Invalid YAML format, {}", err)),
131131
"json" => serde_json::from_str::<serde_json::Value>(content)
132132
.map_err(|err| format!("Invalid JSON format, {}", err)),
@@ -355,14 +355,14 @@ mod tests {
355355

356356
#[test]
357357
fn test_get_version() {
358-
let json = serde_yaml::from_str::<serde_json::Value>("_version: 2").unwrap();
358+
let json = serde_yml::from_str::<serde_json::Value>("_version: 2").unwrap();
359359
assert_eq!(super::get_version(&json), 2);
360360

361-
let json = serde_yaml::from_str::<serde_json::Value>("_version: 1").unwrap();
361+
let json = serde_yml::from_str::<serde_json::Value>("_version: 1").unwrap();
362362
assert_eq!(super::get_version(&json), 1);
363363

364364
// Default fallback to 1
365-
let json = serde_yaml::from_str::<serde_json::Value>("foo: Foo").unwrap();
365+
let json = serde_yml::from_str::<serde_json::Value>("foo: Foo").unwrap();
366366
assert_eq!(super::get_version(&json), 1);
367367
}
368368

0 commit comments

Comments
 (0)