Add a test that every copy key in code exists in both locales

Offen
#29 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
83/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
react-native, typescript

Rechercherichtung

Read apps/mobile/src/a11y-scan.ts and its test for the scanner shape, then packages/copy/src/index.ts for KEY_PATTERN. Add tests in apps/mobile/src/copy-keys.test.ts and cover .ts and .tsx sources under the specified directories, following apps/mobile/src/skill-names.test.ts for package traversal. Run pnpm --filter @hermit/mobile test; done when missing keys are reported with their file names and both locale files are checked.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

agent-friendly copy good first issue

Why

Every string a person sees is a key in packages/copy (AGENTS.md rule 9), and the translator throws on a missing key, so a misspelled key breaks its screen at run time. Nothing checks that the keys the code names exist (VISION.md, principle 5: Spanish and English, first-class).

What to do

Today the copy tests check that both locale files have the same keys and placeholders, and a scan finds about 1,700 literal key references in apps/mobile/src and packages/*/src, all of which resolve. This test guards against the next typo.

  1. Test first. Create apps/mobile/src/copy-keys.ts with a pure function that takes a source file's text and returns the copy keys written in it as whole string literals (in double quotes, single quotes, or backticks with no ${). Use KEY_PATTERN from @hermit/copy (packages/copy/src/index.ts). Follow the shape of apps/mobile/src/a11y-scan.ts and its test.
  2. In apps/mobile/src/copy-keys.test.ts, test the function on made-up source text: a literal key is found; a key built at run time from a template is skipped; a string that isn't a key is skipped. Watch it fail before the function exists.
  3. Add a test that reads every .ts and .tsx file under apps/mobile/src (skipping *.test.ts) and under packages/*/src, collects the keys, and checks that each one is in both packages/copy/locales/en.json and es-419.json. Name the file and the key for each one missing. apps/mobile/src/skill-names.test.ts shows how to walk packages/*/src.
  4. Check that it can fail: misspell one key in a screen on your machine, run the test, see it name the file and the key, then undo the change.

Done when

  • pnpm --filter @hermit/mobile test runs the new tests and they pass.
  • A misspelled key in any screen or package makes the test fail and name the file and the key.

How to check

pnpm --filter @hermit/mobile test
(cd apps/mobile && node --test --experimental-strip-types src/copy-keys.test.ts)

Keep in mind

  • Keys built at run time, like the Device lab's HM-SET-10.failed. followed by a reason, are out of scope. Don't guess them.
  • apps/site has its own locale files. Leave it out.
  • No change to the locale files or the screens, unless the test finds a key that is really missing. Then add it to both locales, with no em or en dashes.
Vorherrschende Sprache
TypeScript
Sterne
11
Forks
0
Ø Merge
10 Min.
Gemergte PRs (30 T.)
6

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus DojoCodingLabs/hermit

Alle Issues in DojoCodingLabs/hermit

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.