agentleFS
parawandererparawanderer/OpenTagViewer/.claude/skills/add-strings/SKILL.md

add-strings

Skill455 starsChanged 32 days agoMITView on GitHub

Add or back-fill user-facing Android strings across all locales in OpenTagViewer. Use whenever adding, renaming or translating any string that appears in the UI, or when checking translations are complete before a PR.

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never pass translations through a shell argument: Write a JSON file with the Write tool, then point the script at it.

    line 14
  2. Distinctive:

    Write the JSON with the Write tool, one entry per string, every locale present:

    line 30
  3. Very specific:

    Put it in the scratchpad or tmp/, not in the repo root.

    line 49
  4. Distinctive:

    Do not hand-delete a string from ten files, for the same reason you do not hand-add one:

    line 79
  5. Very specific:

    Keep positional format specifiers (%1$d, %2$s) intact and in a natural order for the language — they may be reordered, which is the point …

    line 100
  6. Distinctive:

    Do not do these by hand:

    line 106

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Adding user-facing strings

The app ships ten locales. A string missing from one silently falls back to English — nothing fails, and it looks correct in whichever language you happen to read. So every UI string has to land in every locale in one go.

The rule that matters

Never pass translations through a shell argument. Write a JSON file with the Write tool, then point the script at it. Passing non-ASCII text through bash -c, sed or a here-doc has corrupted it twice in this repo — a French apostrophe reached the screen as a literal \’. The Write tool does not go through shell quoting; a for loop does.

For the same reason, do not hand-edit ten strings.xml files with ten Edit calls unless the script cannot do what you need. It is slower and it is what the script exists to replace.

Workflow

  1. Find out which locales are required — do not assume, they are discovered from the tree:

    python scripts/add_strings.py --locales
  2. Write the JSON with the Write tool, one entry per string, every locale present:

    {
      "how_do_i_get_the_zip": {
        "default": "How do I get the zip?",
        "en": "How do I get the zip?",
        "de": "Wie erhalte ich die ZIP-Datei?",
        "fr": "Comment obtenir l’archive zip ?",
        "nl": "Hoe kom ik aan de zip?",
        "ru": "Как получить zip-архив?",
        "ja": "zip ファイルの入手方法",
        "ko": "zip 파일은 어떻게 받나요?",
        "zh-rCN": "如何获取 zip 文件?",
        "zh-rTW": "如何取得 zip 檔案?"
      }
    }

    Put it in the scratchpad or tmp/, not in the repo root.

  3. Apply, then confirm nothing drifted:

    python scripts/add_strings.py tmp/new_strings.json
    python scripts/add_strings.py --check
  4. Build. aapt is the real judge of whether the XML is acceptable:

    JAVA_HOME='C:\Program Files\Android\Android Studio\jbr' ./gradlew.bat :app:assembleDebug

Flags

CommandWhat it does
add_strings.py (no args)Prints full usage and the input format
--localesLists discovered locales and their files
<file.json>Adds strings; errors if any locale is missing or the name already exists
--fill <file.json>Adds only where missing — for back-filling what --check reported
--show <name>...Prints existing strings in the input format, ready to edit
--replace <file.json>Rewords strings that already exist; errors if one is not defined everywhere
--remove <name>...Deletes strings from every locale; errors if a name exists nowhere
--checkFails if any locale lacks a string the default locale has. Run before a PR

Removing and renaming

Do not hand-delete a string from ten files, for the same reason you do not hand-add one:

python scripts/add_strings.py --remove old_name

Renaming is --remove then an ordinary add. Nothing updates references — if a layout or menu still points at a removed string, aapt fails the build, which is how you want to find out.

Rewording something that already exists is --show piped into a file, edited, then --replace. That refuses unless the string is defined in every locale, so a typo in the name fails instead of quietly doing nothing.

Translating

Translate properly rather than leaving English in place; the existing files are fully translated and a stray English string is conspicuous. Points that have come up here:

  • French uses a space before :, ? and !, and reads better with ’ than '
  • CJK wants the full-width colon : and, for a gap, the ideographic space  
  • Keep positional format specifiers (%1$d, %2$s) intact and in a natural order for the language — they may be reordered, which is the point of the positional form
  • Product names (Google Maps, AMap, Anisette) generally stay as they are

What the script already handles

Do not do these by hand:

  • Escaping ', " and & as Android requires
  • Preserving <u>, <b>, <i> so emphasis survives — styling that belongs to the copy belongs in the resource, not in a paint flag in code that would only ever apply to English
  • Re-parsing each file after writing, so a bad write fails immediately instead of at aapt time
  • translatable="false" — set "translatable": false and supply only "default"

Related

AGENTS.md documents this generically for any agent. Keep the two in step if the tool changes.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.