From 4aaebf45cfb10b634f24862aec608e25d0b031d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 25 Oct 2026 08:56:30 +0100 Subject: [PATCH] langtool: add-new-key uses the English string as the placeholder It wrote Key = Key, which for a key like PacketRelayHint that isn't its own English text puts the key name itself in the UI of every untranslated language. Now it takes the value from en_US.ini, falling back to the key. Co-Authored-By: Claude Opus 5.5 (1M context) --- .claude/commands/add-string.md | 2 +- Tools/langtool/src/main.rs | 10 +++++++++- docs/translations.md | 5 +++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.claude/commands/add-string.md b/.claude/commands/add-string.md index e63fd6ded7..782c225097 100644 --- a/.claude/commands/add-string.md +++ b/.claude/commands/add-string.md @@ -70,7 +70,7 @@ Follow the workflow in docs/translations.md. Run langtool from translations, check what you're about to replace first. The section has to exist already. 4. `cargo run -- add-new-key "
" ""` - **always, every language file ends up with the - key.** This writes `Key = Key` (plain English, no `# same as English` marker, so it still reads + key.** This writes the English string from `en_US.ini` (no `# same as English` marker, so it still reads as outstanding work) into every language you skipped, and leaves the ones you translated alone. A missing key would fall back to the English string at runtime anyway, but then it looks exactly like a translated one in the files, and translators can't see what's left to do. diff --git a/Tools/langtool/src/main.rs b/Tools/langtool/src/main.rs index fc129b1da6..8f2b6935d4 100644 --- a/Tools/langtool/src/main.rs +++ b/Tools/langtool/src/main.rs @@ -950,7 +950,15 @@ fn execute_command(cmd: Command, ai: Option<&Ai>, dry_run: bool, verbose: bool) Command::AddNewKey { ref section, ref key, - } => add_new_key(&mut target_ini, section, key, key, false).unwrap(), + } => { + // The placeholder is the English string. That's the key itself for most keys, + // but not for ones like "PacketRelayHint", which would otherwise show up as-is. + let english = reference_ini + .get_section(section) + .and_then(|s| s.get_value(key)) + .unwrap_or_else(|| key.clone()); + add_new_key(&mut target_ini, section, key, &english, false).unwrap() + } Command::AddNewKeyAI { ref section, ref key, diff --git a/docs/translations.md b/docs/translations.md index 2ab7cd5b7c..d5dbf81066 100644 --- a/docs/translations.md +++ b/docs/translations.md @@ -37,8 +37,9 @@ from `Tools/langtool`: already have human translations, and that the section has to exist already - langtool won't create one. 4. `cargo run -- add-new-key
""` gives every language you skipped the English string - as a placeholder - `Key = Key`, with no `# same as English` marker, so it still reads as - outstanding work - and leaves the translated ones untouched. Always do this: every language file + as a placeholder - the key's value in en_US.ini, usually the key itself, with no + `# same as English` marker, so it still reads as outstanding work - and leaves the translated + ones untouched. Always do this: every language file should end up with the key. A missing key falls back to English at runtime anyway, but in the files it's indistinguishable from a translated one, so translators can't see what's left. `copy-missing-lines` does the same job across every key in the repo at once, which is a different