feat(i18n): dashboard key audit + add 14 missing source keys across 8 locales#61
Conversation
Adds scripts/audit-frontend-keys.mjs — an AST-based (TypeScript compiler API) auditor that extracts every t() key the core_api dashboard frontend references and diffs them against the en-US source-of-truth JSON and the bundled fallback. Emits machine- and human-readable reports under docs/audits/. Un-ignores docs/audits/ so reports are tracked deliverables. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ales (audit M1) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
CodeAnt AI is reviewing your PR. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
CodeAnt AI finished reviewing your PR. |
Greptile SummaryThis PR adds two reusable AST-based audit scripts (
Confidence Score: 5/5Safe to merge — the locale additions are additive JSON-only changes verified by the existing parity test suite, and the audit scripts are developer tooling with no runtime impact on the application. All locale files are additive: no existing keys are modified, interpolation placeholders are preserved verbatim, and the parity suite confirms key-set consistency across all 8 locales. The two new scripts are offline tooling that only run on demand in a worktree environment and do not affect the deployed application. No files require special attention. The locale JSON changes are straightforward additions and the audit scripts are dev-tooling only.
|
| Filename | Overview |
|---|---|
| scripts/audit-frontend-keys.mjs | New AST-based key-reference audit script; well-structured with proper existsSync guard, AST disambiguation heuristic, and comprehensive reporting. Default output paths embed a hardcoded date that would produce misleading filenames on re-runs. |
| scripts/audit-hardcoded-strings.mjs | New heuristic JSX/attribute scanner for un-localized strings; false-positive mitigations are solid. Same hardcoded-date default path issue as the sibling script. |
| packages/i18n/locales/en-US/common.json | Adds nav.noProgram and 13 app.admin.aiAdvisor.* keys; interpolation placeholders match the frontend call sites per the audit. |
| packages/i18n/locales/fr/common.json | All 14 keys added with appropriate French translations; key structure and placeholder tokens are consistent with the en-US source. |
| packages/i18n/locales/es-ES/common.json | 14 keys added; translations are identical to es-MX for all new entries, acceptable for these technical/UI terms but worth a future review pass once Lokalise is synced. |
| packages/i18n/locales/pt-BR/common.json | 14 keys added with correct Brazilian Portuguese translations; differs appropriately from pt-PT (e.g. 'em tempo real' vs 'em direto'). |
| docs/audits/2026-06-04-frontend-key-audit.md | Point-in-time audit report confirming 0 broken key references and 14 missing keys (pre-fix snapshot); committed as a reproducible baseline. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[core_api frontend *.ts/tsx] -->|AST scan| B[audit-frontend-keys.mjs]
C[en-US locale JSON] --> B
D[i18n-utils.ts bundle fallback] --> B
B --> E{Classify keys}
E -->|Missing from JSON, in bundle| F[M1 — add to locale JSON]
E -->|Missing from JSON AND bundle| G[M3 — code bug]
E -->|Template literal / variable| H[Dynamic — manual review]
E -->|Present in JSON| I[OK ✅]
F --> J[packages/i18n/locales/*/common.json\n14 keys added across 8 locales]
J --> K[Parity test suite\n228 pass / 9 skip ✅]
A -->|JSX scan| L[audit-hardcoded-strings.mjs]
L --> M[469 un-localized strings\nacross 66 files — triage list]
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 2
scripts/audit-frontend-keys.mjs:80-82
**Hardcoded date in default output path makes re-runs misleading**
The default `outJson` / `outMd` values bake in `2026-06-04-` as a literal string. If someone re-runs the audit on any later date — for example, after the Lokalise sync mentioned in the PR description — the output is silently written to a file whose name implies it was produced on June 4 2026, overwriting or shadowing the original snapshot. Using a computed date (e.g. `new Date().toISOString().slice(0, 10)`) for the default prefix would make repeated runs self-labelling and prevent stale filenames from masking diff history.
### Issue 2 of 2
scripts/audit-hardcoded-strings.mjs:66-68
**Same hardcoded-date default path concern as the sibling script**
`outJson` and `outMd` default to filenames with `2026-06-04-` embedded, so re-running the audit on a different date produces misdated output. Same fix applies: derive the date portion dynamically from `new Date().toISOString().slice(0, 10)`.
Reviews (2): Last reviewed commit: "fix(audit): namespace-resolved key match..." | Re-trigger Greptile
…Sync fixes (codeant+greptile) - audit-frontend-keys: classify refs against their RESOLVED namespace only (drop inJsonAnywhere/inBundleAnywhere); surface wrong-namespace refs in a new informational `namespaceMismatch` category instead of hiding them or forcing into M1/M3. - audit-frontend-keys: add existsSync guard to collectFiles (parity with sibling). - both scripts: mkdir the markdown out-dir before writing (was ENOENT on a missing --out-md dir). - audit-hardcoded-strings: escape hyphen in className char class so `%-:` is not an unintended range (no longer matches & ' ( ) * + ,). - regenerate committed reports against current locale: M1=0, M3=0, namespaceMismatch=0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@greptile review |
User description
Summary
Supports the companion core_api fix (loyaltydog/core_api#805) that resolves raw i18n keys leaking into the dashboard. Adds reusable audit tooling and closes the source-JSON key gaps the audit found.
Audit findings
A new AST-based audit of the core_api frontend (716 files, 1,858 unique referenced keys) found:
app.admin.aiAdvisor.*+nav.noProgram.Changes
scripts/audit-frontend-keys.mjs— reusable referenced-key vs source/bundle diff (overridable paths for other consumer repos).scripts/audit-hardcoded-strings.mjs— heuristic un-localized JSX/attribute text scanner.docs/audits/2026-06-04-*— both reports (point-in-time, pre-fix snapshot).packages/i18n/locales/*/common.json— added the 14 keys to all 8 locales with proper translations ("AI"→"IA" matching existing terminology; interpolation placeholders{{description}}/{{source}}/{{count}}preserved exactly).Verification
Note
The 14 keys were translated directly to keep parity green and the app working immediately, rather than via the
lokalise:upload→ AI → CI sync path. A later Lokalise sync will reconcile to the same state.🤖 Generated with Claude Code
CodeAnt-AI Description
Add frontend i18n audit reports and fill missing dashboard keys
What Changed
nav.noProgramandapp.admin.aiAdvisor.*strings across supported locales so the dashboard can show these labels without falling back to raw keysImpact
✅ Fewer raw translation keys in the dashboard✅ Clearer AI Advisor labels and status messages✅ Easier detection of untranslated dashboard copy💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.