Skip to content

Commit

Permalink
langtool: When renaming the key of untranslated strings, also change …
Browse files Browse the repository at this point in the history
…the value.
  • Loading branch information
hrydgard committed Nov 30, 2023
1 parent 737ec3e commit 75a59d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Tools/langtool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,12 @@ fn main() {
ref section,
ref old,
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 {
ref old,
ref new,
Expand Down
7 changes: 6 additions & 1 deletion Tools/langtool/src/section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ impl Section {
}
if let Some(index) = found_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);
} else {
let name = &self.name;
Expand Down

0 comments on commit 75a59d1

Please sign in to comment.