Skip to content

Commit

Permalink
langtool: improve insertion of missing sections (logging, empty line)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Dec 12, 2022
1 parent c1c5c6c commit 4802e78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Tools/langtool/src/inifile.rs
Expand Up @@ -111,6 +111,10 @@ impl IniFile {
}
}
// Reached the end for some reason? Add it.
// Also add an empty line to the previous section.
if let Some(last) = self.sections.last_mut() {
last.lines.push("".into());
}
self.sections.push(section.clone());
true
}
Expand Down
7 changes: 6 additions & 1 deletion Tools/langtool/src/main.rs
Expand Up @@ -47,6 +47,10 @@ fn copy_missing_lines(reference_ini: &IniFile, target_ini: &mut IniFile) -> io::
//target_section.remove_lines_if_not_in(reference_section);
target_section.comment_out_lines_if_not_in(reference_section);
}
} else {
// Note: insert_section_if_missing will copy the entire section,
// no need to loop over the lines here.
println!("Inserted missing section: {}", reference_section.name);
}
}
Ok(())
Expand Down Expand Up @@ -114,7 +118,8 @@ fn main() {
let root = "../../assets/lang";
let reference_ini_filename = "en_US.ini";

let mut reference_ini = IniFile::parse(&format!("{}/{}", root, reference_ini_filename)).unwrap();
let mut reference_ini =
IniFile::parse(&format!("{}/{}", root, reference_ini_filename)).unwrap();

if filenames.is_empty() {
// Grab them all.
Expand Down

0 comments on commit 4802e78

Please sign in to comment.