langtool: When renaming the key of untranslated strings, also change the value.

This commit is contained in:
Henrik Rydgård 2023-11-30 17:21:29 +01:00
parent 737ec3e90b
commit 75a59d100a
2 changed files with 12 additions and 2 deletions

View file

@ -242,7 +242,12 @@ fn main() {
ref section, ref section,
ref old, ref old,
ref new, ref new,
} => rename_key(&mut reference_ini, section, old, new).unwrap(), } => {
if old == new {
println!("WARNING: old == new");
}
rename_key(&mut reference_ini, section, old, new).unwrap();
}
Command::MoveKey { Command::MoveKey {
ref old, ref old,
ref new, ref new,

View file

@ -92,7 +92,12 @@ impl Section {
} }
if let Some(index) = found_index { if let Some(index) = found_index {
let line = self.lines.remove(index); let line = self.lines.remove(index);
let line = new.to_owned() + " =" + line.strip_prefix(&prefix).unwrap(); let mut right_part = line.strip_prefix(&prefix).unwrap().to_string();
if right_part.trim() == old.trim() {
// Was still untranslated - replace the translation too.
right_part = format!(" {}", new);
}
let line = new.to_owned() + " =" + &right_part;
self.insert_line_if_missing(&line); self.insert_line_if_missing(&line);
} else { } else {
let name = &self.name; let name = &self.name;