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) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-25 08:57:51 +01:00
1 parent c3fb7ae2c1
commit 4aaebf45cf
3 files changed
+13 -4

No files matched your search

+1 -1
View File
@@ -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 "<Section>" "<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.
+9 -1
View File
@@ -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,
+3 -2
View File
@@ -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 <Section> "<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