From f6655d8b62066c816e81a37920f0e6c20d2e4b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 18 Sep 2026 13:18:45 -0600 Subject: [PATCH] add-string: read the invocation instead of splitting it The command took $1/$2/$3 off the front of whatever was typed, so it only got the right section and key when called in exactly the documented shape. Called with a sentence - which is the natural way to ask for this - it silently produced three arbitrary words, and a paragraph warning about that is a poor substitute for not doing it. It now gets $ARGUMENTS whole and works the three values out, which is the part that needed a model anyway. Co-Authored-By: Claude Opus 5 (1M context) --- .claude/commands/add-string.md | 36 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/.claude/commands/add-string.md b/.claude/commands/add-string.md index aa3a3dc71d..e548f93d46 100644 --- a/.claude/commands/add-string.md +++ b/.claude/commands/add-string.md @@ -5,18 +5,22 @@ argument-hint:
"" [""] Add and/or translate a PPSSPP UI string. -- Section: `$1` -- Key: `$2` -- English string: `$3` - if this is empty, the key already exists in `assets/lang/en_US.ini` and - you're only filling in the languages where it's still untranslated. +What was asked for: `$ARGUMENTS` -Those three are split off the invocation positionally, so they're only right if it was called as -`/add-string
"" [""]`. Called with a sentence instead, they'll be -three arbitrary words - so **check them before you touch anything**: `$1` has to be a real `[Section]` -in `assets/lang/en_US.ini`, and `$2` a key that exists under it (or, for a new string, one that -doesn't exist anywhere yet and that you can find in the C++). If they don't hold up, work out the -real section and key from what was actually asked for, say which values you settled on, and carry on -from there - don't translate whatever the positional split happened to produce. +Work out three things from that, and **say which values you settled on before you touch anything**: + +- **Section** - a `[Section]` that exists in `assets/lang/en_US.ini`. Check that it does. +- **Key** - for a new string this is the English text itself, which is how keys are written here; for + an existing one it is the key as `en_US.ini` spells it, character for character. +- **English string** - only for a new key. If the key is already in `en_US.ini` there is no English + string to pass, and the job is filling in the languages where it is still untranslated. + +The invocation may be `
"" [""]`, or an ordinary sentence naming the +section and the string, or just the string. Read it, don't split it on whitespace and hope: three +words off the front of a sentence are three arbitrary words, and translating those quietly writes +rubbish into 47 files. When the section or key isn't stated outright, find them - grep the C++ for +the string to see which `GetI18NCategory` it belongs to, and `en_US.ini` for whether the key is +already there. Ask only if that leaves it genuinely ambiguous. Follow the workflow in docs/translations.md. Run langtool from `Tools/langtool`: @@ -60,15 +64,15 @@ Follow the workflow in docs/translations.md. Run langtool from with a `# same as English` comment, which is what stops langtool from trying to translate it again on every later run. -3. `cargo run -- import-single "$1" "$2"` +3. `cargo run -- import-single "
" ""` Note this overwrites any existing value for that key, so if the key already had human translations, check what you're about to replace first. The section has to exist already. -4. `cargo run -- add-new-key "$1" "$2"` - **always, every language file ends up with the key.** This - writes `Key = Key` (plain English, 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 +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 + 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. Don't reach for `copy-missing-lines` to do this - it fills in placeholders repo-wide, and drags