From 75a59d100a6f405d61ffe5b60a37823e1b792f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 30 Nov 2023 17:21:29 +0100 Subject: [PATCH] langtool: When renaming the key of untranslated strings, also change the value. --- Tools/langtool/src/main.rs | 7 ++++++- Tools/langtool/src/section.rs | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Tools/langtool/src/main.rs b/Tools/langtool/src/main.rs index ebe82ad8f..6e2a0a372 100644 --- a/Tools/langtool/src/main.rs +++ b/Tools/langtool/src/main.rs @@ -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, diff --git a/Tools/langtool/src/section.rs b/Tools/langtool/src/section.rs index f845d6071..34120de60 100644 --- a/Tools/langtool/src/section.rs +++ b/Tools/langtool/src/section.rs @@ -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;