From f947f76d005f4bd5731ce20269d755363d4a2d19 Mon Sep 17 00:00:00 2001 From: Andrea Ricchi Date: Thu, 9 May 2024 11:19:08 +0200 Subject: [PATCH] dart_to_csv: remove multiline translation support Multiline translations is a bad practice and should not be supported. Also the multiline support was causing problems when parsing standard translations. Fixed the dart_to_csv generation. Signed-off-by: Andrea Ricchi --- src/dart_to_csv.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/dart_to_csv.rs b/src/dart_to_csv.rs index a82ceb4..b51962d 100644 --- a/src/dart_to_csv.rs +++ b/src/dart_to_csv.rs @@ -21,21 +21,14 @@ fn read_file(path: String) -> Vec { let mut translations = Vec::new(); if let Ok(lines) = read_lines(path) { - let mut previous_line = String::new(); - for ip in lines.flatten() { - let start_bytes = ip.find('\'').unwrap_or(0); - let end_bytes = ip.find(".tr,").unwrap_or(ip.len()); - let mut result = (ip[start_bytes..end_bytes]).to_string(); - - if !ip.ends_with(".tr,") { - previous_line = result; + if !ip.contains("'.tr") { continue; } - if !previous_line.is_empty() && previous_line.ends_with('\'') && ip.ends_with(".tr,") { - result = previous_line.clone(); - } + let start_bytes = ip.find('\'').unwrap_or(0); + let end_bytes = ip.find("'.tr").unwrap_or(ip.len()); + let mut result = (ip[start_bytes..end_bytes]).to_string(); if result.trim().is_empty() { continue;