diff --git a/Cargo.lock b/Cargo.lock index 5206b97b..79d706c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -184,7 +184,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -217,7 +217,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -234,7 +234,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -251,7 +251,7 @@ checksum = "edf3ee19dbc0a46d740f6f0926bde8c50f02bdbc7b536842da28f6ac56513a8b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -420,6 +420,15 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "casey" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614586263949597dcc18675da12ef9b429135e13628d92eb8b8c6fa50ca5656b" +dependencies = [ + "syn 1.0.109", +] + [[package]] name = "cast" version = "0.3.0" @@ -856,7 +865,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -922,7 +931,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -1182,7 +1191,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -1612,6 +1621,7 @@ name = "hemtt-stringtable" version = "1.0.0" dependencies = [ "automod", + "casey", "hemtt-common", "hemtt-workspace", "insta", @@ -1685,7 +1695,7 @@ dependencies = [ "markup5ever", "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -2027,7 +2037,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -2287,7 +2297,7 @@ checksum = "b01f197a15988fb5b2ec0a5a9800c97e70771499c456ad757d63b3c5e9b96e75" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -2649,7 +2659,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -2799,7 +2809,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -2929,7 +2939,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -3017,7 +3027,7 @@ checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -3152,7 +3162,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a65f2e60fbf1063868558d69c6beacf412dc755f9fc020f514b7955fc914fe30" dependencies = [ "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -3460,7 +3470,7 @@ checksum = "a5a11a05ee1ce44058fa3d5961d05194fdbe3ad6b40f904af764d81b86450e6b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -3529,7 +3539,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn", + "syn 2.0.85", "walkdir", ] @@ -3674,7 +3684,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77253fb2d4451418d07025826028bcb96ee42d3e58859689a70ce62908009db6" dependencies = [ "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -3734,7 +3744,7 @@ checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -3757,7 +3767,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -4048,7 +4058,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 2.0.85", ] [[package]] @@ -4063,6 +4073,17 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c0a1e5168041f5f3ff68ff7d95dcb9c8749df29f6e7e89ada40dd4c9de404ee" +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.85" @@ -4215,7 +4236,7 @@ checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -4330,7 +4351,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -4479,7 +4500,7 @@ checksum = "84fd902d4e0b9a4b27f2f440108dc034e1758628a9b702f8ec61ad66355422fa" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -4508,7 +4529,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -4581,7 +4602,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568" dependencies = [ "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -4830,7 +4851,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.85", "wasm-bindgen-shared", ] @@ -4864,7 +4885,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5266,7 +5287,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] @@ -5286,7 +5307,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.85", ] [[package]] diff --git a/libs/stringtable/Cargo.toml b/libs/stringtable/Cargo.toml index 04f02442..15196bea 100644 --- a/libs/stringtable/Cargo.toml +++ b/libs/stringtable/Cargo.toml @@ -13,6 +13,7 @@ hemtt-common = { path = "../common", version = "1.0.0" } hemtt-workspace = { path = "../workspace", version = "1.0.0" } automod = { workspace = true } +casey = "0.4" linkme = { workspace = true } paste = { workspace = true } quick-xml = { version = "0.37.0", features = ["serialize"] } diff --git a/libs/stringtable/src/key.rs b/libs/stringtable/src/key.rs index e3a5805c..37d4eb17 100644 --- a/libs/stringtable/src/key.rs +++ b/libs/stringtable/src/key.rs @@ -1,57 +1,92 @@ -use serde::{Deserialize, Serialize}; +use quick_xml::escape::minimal_escape; +use serde::{Deserialize, Serialize, Serializer}; + +fn min_escape(s: &Option, ser: S) -> Result +where + S: Serializer, +{ + match s { + Some(s) => ser.serialize_str(&minimal_escape(s)), + None => ser.serialize_none(), + } +} #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "PascalCase")] pub struct Key { #[serde(rename = "@ID")] id: String, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "original", alias = "ORIGINAL")] original: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "english", alias = "ENGLISH")] english: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "czech", alias = "CZECH")] czech: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "french", alias = "FRENCH")] french: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "spanish", alias = "SPANISH")] spanish: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "italian", alias = "ITALIAN")] italian: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "polish", alias = "POLISH")] polish: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "portuguese", alias = "PORTUGUESE")] portuguese: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "russian", alias = "RUSSIAN")] russian: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "german", alias = "GERMAN")] german: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "korean", alias = "KOREAN")] korean: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "japanese", alias = "JAPANESE")] japanese: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "chinese", alias = "CHINESE")] chinese: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "chinesesimp", alias = "CHINESESIMP")] chinesesimp: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "turkish", alias = "TURKISH")] turkish: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "swedish", alias = "SWEDISH")] swedish: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "slovak", alias = "SLOVAK")] slovak: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "serbocroatian", alias = "SERBOCROATIAN")] serbocroatian: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "norwegian", alias = "NORWEGIAN")] norwegian: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "icelandic", alias = "ICELANDIC")] icelandic: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "hungarian", alias = "HUNGARIAN")] hungarian: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "greek", alias = "GREEK")] greek: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "finnish", alias = "FINNISH")] finnish: Option, - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing_if = "Option::is_none", serialize_with = "min_escape")] + #[serde(alias = "dutch", alias = "DUTCH")] dutch: Option, } diff --git a/libs/stringtable/src/lib.rs b/libs/stringtable/src/lib.rs index e1ac0c98..cabe7bb5 100644 --- a/libs/stringtable/src/lib.rs +++ b/libs/stringtable/src/lib.rs @@ -21,7 +21,7 @@ pub struct Project { packages: Vec, #[serde(skip)] - meta_comments: Vec<(String, String)>, + meta_comments: Vec<(String, String, Option)>, } impl Project { @@ -50,6 +50,7 @@ impl Project { let mut buffer = String::new(); let mut reading_comments = false; let mut comments = Vec::new(); + let mut in_key = None; let Ok(reader) = reader .lines() .map(|l| { @@ -57,20 +58,38 @@ impl Project { error!("Failed to read line: {:?}", l); return l; }; - if !reading_comments && !buffer.is_empty() { - comments.push((buffer.trim().to_string(), l.trim().to_string())); - buffer.clear(); + let l_trim = l.trim(); + if reading_comments { + buffer.push('\n'); } - if l.trim().starts_with("") { + if l_trim.ends_with("-->") { reading_comments = false; } } - Ok(l) + if !reading_comments { + if l_trim.starts_with("") { + in_key = None; + } + } + Ok(l.replace('&', "&")) }) .collect::, _>>() else { @@ -96,23 +115,40 @@ impl Project { let mut buffer = String::new(); let mut ser = Serializer::new(&mut buffer); ser.indent(' ', 4); + ser.expand_empty_elements(true); self.serialize(ser)?; buffer.push('\n'); + let mut clear_next = false; + let mut in_key = None; for line in buffer.lines() { - for (before, after) in &self.meta_comments { - if line.trim().starts_with(after) { - let whitespace = line + let l_trim = line.trim(); + if clear_next { + clear_next = false; + in_key = None; + } + for (before, after, key) in &self.meta_comments { + if l_trim.starts_with(after) && &in_key == key { + let mut whitespace = line .chars() .take_while(|c| c.is_whitespace()) .collect::(); + if l_trim.starts_with("") { + clear_next = true; + } } Ok(()) diff --git a/libs/stringtable/tests/comments.rs b/libs/stringtable/tests/comments.rs new file mode 100644 index 00000000..eb2be672 --- /dev/null +++ b/libs/stringtable/tests/comments.rs @@ -0,0 +1,23 @@ +#![allow(clippy::unwrap_used)] + +use std::io::BufReader; + +use hemtt_stringtable::Project; + +#[test] +fn sort() { + let mut stringtable = Project::from_reader(BufReader::new( + std::fs::File::open("tests/comments.xml").unwrap(), + )) + .unwrap(); + insta::assert_debug_snapshot!(stringtable); + + stringtable.sort(); + + insta::assert_debug_snapshot!(stringtable); + + let mut out = String::new(); + stringtable.to_writer(&mut out).unwrap(); + + insta::assert_snapshot!(out); +} diff --git a/libs/stringtable/tests/comments.xml b/libs/stringtable/tests/comments.xml new file mode 100644 index 00000000..0e657578 --- /dev/null +++ b/libs/stringtable/tests/comments.xml @@ -0,0 +1,17 @@ + + + + + Das ist eine Zeichenkette ohne Kommentar + Esto es una cadena sin un comentario + + This is a string with a comment + + + + Das ist eine Zeichenkette ohne Kommentar + + This is a string with a comment + + + diff --git a/libs/stringtable/tests/gh822.rs b/libs/stringtable/tests/gh822.rs new file mode 100644 index 00000000..5021e7a0 --- /dev/null +++ b/libs/stringtable/tests/gh822.rs @@ -0,0 +1,21 @@ +#![allow(clippy::unwrap_used)] + +use std::io::BufReader; + +use hemtt_stringtable::Project; + +#[test] +fn sort() { + let mut stringtable = Project::from_reader(BufReader::new( + std::fs::File::open("tests/gh822.xml").unwrap(), + )) + .unwrap(); + stringtable.sort(); + + insta::assert_debug_snapshot!(stringtable); + + let mut out = String::new(); + stringtable.to_writer(&mut out).unwrap(); + + insta::assert_snapshot!(out); +} diff --git a/libs/stringtable/tests/gh822.xml b/libs/stringtable/tests/gh822.xml new file mode 100644 index 00000000..bcbdf43e --- /dev/null +++ b/libs/stringtable/tests/gh822.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + hey + hey + hey + hey + + + "' + "' + "' + "' + "Hello World" + + + + I leave this for later + I leave this for later + + + + + + + diff --git a/libs/stringtable/tests/snapshots/comments__sort-2.snap b/libs/stringtable/tests/snapshots/comments__sort-2.snap new file mode 100644 index 00000000..2b375156 --- /dev/null +++ b/libs/stringtable/tests/snapshots/comments__sort-2.snap @@ -0,0 +1,100 @@ +--- +source: libs/stringtable/tests/comments.rs +expression: stringtable +--- +Project { + name: "HEMTT", + packages: [ + Package { + name: "Test", + keys: [ + Key { + id: "HasComment", + original: None, + english: Some( + "This is a string with a comment", + ), + czech: None, + french: None, + spanish: None, + italian: None, + polish: None, + portuguese: None, + russian: None, + german: Some( + "Das ist eine Zeichenkette ohne Kommentar", + ), + korean: None, + japanese: None, + chinese: None, + chinesesimp: None, + turkish: None, + swedish: None, + slovak: None, + serbocroatian: None, + norwegian: None, + icelandic: None, + hungarian: None, + greek: None, + finnish: None, + dutch: None, + }, + Key { + id: "HasNoComment", + original: None, + english: Some( + "This is a string with a comment", + ), + czech: None, + french: None, + spanish: Some( + "Esto es una cadena sin un comentario", + ), + italian: None, + polish: None, + portuguese: None, + russian: None, + german: Some( + "Das ist eine Zeichenkette ohne Kommentar", + ), + korean: None, + japanese: None, + chinese: None, + chinesesimp: None, + turkish: None, + swedish: None, + slovak: None, + serbocroatian: None, + norwegian: None, + icelandic: None, + hungarian: None, + greek: None, + finnish: None, + dutch: None, + }, + ], + containers: [], + }, + ], + meta_comments: [ + ( + "", + "This is a string with a comment", + Some( + "", + ), + ), + ( + "", + "This is a string with a comment", + Some( + "", + ), + ), + ( + "", + "", + None, + ), + ], +} diff --git a/libs/stringtable/tests/snapshots/comments__sort-3.snap b/libs/stringtable/tests/snapshots/comments__sort-3.snap new file mode 100644 index 00000000..22d214a3 --- /dev/null +++ b/libs/stringtable/tests/snapshots/comments__sort-3.snap @@ -0,0 +1,21 @@ +--- +source: libs/stringtable/tests/comments.rs +expression: out +--- + + + + + + + This is a string with a comment + Das ist eine Zeichenkette ohne Kommentar + + + + This is a string with a comment + Esto es una cadena sin un comentario + Das ist eine Zeichenkette ohne Kommentar + + + diff --git a/libs/stringtable/tests/snapshots/comments__sort.snap b/libs/stringtable/tests/snapshots/comments__sort.snap new file mode 100644 index 00000000..dcd53485 --- /dev/null +++ b/libs/stringtable/tests/snapshots/comments__sort.snap @@ -0,0 +1,100 @@ +--- +source: libs/stringtable/tests/comments.rs +expression: stringtable +--- +Project { + name: "HEMTT", + packages: [ + Package { + name: "Test", + keys: [ + Key { + id: "HasNoComment", + original: None, + english: Some( + "This is a string with a comment", + ), + czech: None, + french: None, + spanish: Some( + "Esto es una cadena sin un comentario", + ), + italian: None, + polish: None, + portuguese: None, + russian: None, + german: Some( + "Das ist eine Zeichenkette ohne Kommentar", + ), + korean: None, + japanese: None, + chinese: None, + chinesesimp: None, + turkish: None, + swedish: None, + slovak: None, + serbocroatian: None, + norwegian: None, + icelandic: None, + hungarian: None, + greek: None, + finnish: None, + dutch: None, + }, + Key { + id: "HasComment", + original: None, + english: Some( + "This is a string with a comment", + ), + czech: None, + french: None, + spanish: None, + italian: None, + polish: None, + portuguese: None, + russian: None, + german: Some( + "Das ist eine Zeichenkette ohne Kommentar", + ), + korean: None, + japanese: None, + chinese: None, + chinesesimp: None, + turkish: None, + swedish: None, + slovak: None, + serbocroatian: None, + norwegian: None, + icelandic: None, + hungarian: None, + greek: None, + finnish: None, + dutch: None, + }, + ], + containers: [], + }, + ], + meta_comments: [ + ( + "", + "This is a string with a comment", + Some( + "", + ), + ), + ( + "", + "This is a string with a comment", + Some( + "", + ), + ), + ( + "", + "", + None, + ), + ], +} diff --git a/libs/stringtable/tests/snapshots/gh822__sort-2.snap b/libs/stringtable/tests/snapshots/gh822__sort-2.snap new file mode 100644 index 00000000..870600d5 --- /dev/null +++ b/libs/stringtable/tests/snapshots/gh822__sort-2.snap @@ -0,0 +1,43 @@ +--- +source: libs/stringtable/tests/gh822.rs +expression: out +--- + + + + + + I leave this for later + I leave this for later + + + + + + hey + hey + hey + hey + + + + + + + + + + "' + "' + "Hello World" + "' + "' + + + + diff --git a/libs/stringtable/tests/snapshots/gh822__sort.snap b/libs/stringtable/tests/snapshots/gh822__sort.snap new file mode 100644 index 00000000..64a2afdc --- /dev/null +++ b/libs/stringtable/tests/snapshots/gh822__sort.snap @@ -0,0 +1,177 @@ +--- +source: libs/stringtable/tests/gh822.rs +expression: stringtable +--- +Project { + name: "test", + packages: [ + Package { + name: "test", + keys: [ + Key { + id: "Comments be gone!", + original: Some( + "I leave this for later", + ), + english: Some( + "I leave this for later", + ), + czech: None, + french: None, + spanish: None, + italian: None, + polish: None, + portuguese: None, + russian: None, + german: None, + korean: None, + japanese: None, + chinese: None, + chinesesimp: None, + turkish: None, + swedish: None, + slovak: None, + serbocroatian: None, + norwegian: None, + icelandic: None, + hungarian: None, + greek: None, + finnish: None, + dutch: None, + }, + Key { + id: "I will be empty", + original: Some( + "hey", + ), + english: Some( + "hey", + ), + czech: None, + french: None, + spanish: None, + italian: None, + polish: None, + portuguese: None, + russian: Some( + "hey", + ), + german: Some( + "hey", + ), + korean: None, + japanese: None, + chinese: None, + chinesesimp: None, + turkish: None, + swedish: None, + slovak: None, + serbocroatian: None, + norwegian: None, + icelandic: None, + hungarian: None, + greek: None, + finnish: None, + dutch: None, + }, + Key { + id: "I will change the xml structure a little", + original: Some( + "", + ), + english: Some( + "", + ), + czech: Some( + "", + ), + french: Some( + "", + ), + spanish: None, + italian: None, + polish: None, + portuguese: None, + russian: None, + german: None, + korean: None, + japanese: None, + chinese: None, + chinesesimp: None, + turkish: None, + swedish: None, + slovak: None, + serbocroatian: None, + norwegian: None, + icelandic: None, + hungarian: None, + greek: None, + finnish: None, + dutch: None, + }, + Key { + id: "My things get unescaped", + original: Some( + ""'", + ), + english: Some( + ""'", + ), + czech: None, + french: None, + spanish: Some( + "\"Hello World\"", + ), + italian: None, + polish: None, + portuguese: None, + russian: Some( + ""'", + ), + german: Some( + ""'", + ), + korean: None, + japanese: None, + chinese: None, + chinesesimp: None, + turkish: None, + swedish: None, + slovak: None, + serbocroatian: None, + norwegian: None, + icelandic: None, + hungarian: None, + greek: None, + finnish: None, + dutch: None, + }, + ], + containers: [], + }, + ], + meta_comments: [ + ( + "", + "", + None, + ), + ( + "\n \n ", + "", + Some( + "", + ), + ), + ( + "", + "", + None, + ), + ( + "", + "", + None, + ), + ], +}