Skip to content

Commit

Permalink
dart_to_csv: remove multiline translation support
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
AndreaRicchi committed May 9, 2024
1 parent fcd7111 commit f947f76
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/dart_to_csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,14 @@ fn read_file(path: String) -> Vec<String> {
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;
Expand Down

0 comments on commit f947f76

Please sign in to comment.