Skip to content

feat(i18n): dashboard key audit + add 14 missing source keys across 8 locales#61

Merged
haim-barad merged 4 commits into
mainfrom
feat/dashboard-i18n-audit
Jun 4, 2026
Merged

feat(i18n): dashboard key audit + add 14 missing source keys across 8 locales#61
haim-barad merged 4 commits into
mainfrom
feat/dashboard-i18n-audit

Conversation

@haim-barad

@haim-barad haim-barad commented Jun 4, 2026

Copy link
Copy Markdown
Member

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:

  • 0 broken static key references (no wrong-path/casing bugs) — the dashboard raw-keys issue was a delivery problem, fixed in the core_api PR.
  • 14 keys referenced by the frontend but missing from the source-of-truth JSON (they only existed in the frontend's English fallback bundle): 13 app.admin.aiAdvisor.* + nav.noProgram.
  • 469 hardcoded (un-localized) strings across 66 files (triage list — largest surface is the Shopify storefront form). Separate follow-up effort.

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

  • Parity test suite green (228 pass / 9 skipped) — all 8 locales hold identical key sets.
  • Re-running the audit after the additions: M1 (missing) 14 → 0, M3 (broken) 0.

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

  • Added a key-reference audit that lists missing translation keys, bundle mismatches, and dynamic keys needing review
  • Added a hardcoded-text audit report to surface untranslated user-facing copy across the dashboard
  • Added the missing nav.noProgram and app.admin.aiAdvisor.* strings across supported locales so the dashboard can show these labels without falling back to raw keys
  • Updated the English, Spanish, French, Portuguese, and Italian locale files with the new AI Advisor and “no program selected” text

Impact

✅ 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:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

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:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

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.

haim-barad and others added 3 commits June 4, 2026 19:26
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

codeant-ai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

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 ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files label Jun 4, 2026
Comment thread scripts/audit-frontend-keys.mjs Outdated
Comment thread scripts/audit-frontend-keys.mjs
Comment thread scripts/audit-hardcoded-strings.mjs
@codeant-ai

codeant-ai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

CodeAnt AI finished reviewing your PR.

@greptile-apps

greptile-apps Bot commented Jun 4, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds two reusable AST-based audit scripts (audit-frontend-keys.mjs, audit-hardcoded-strings.mjs) and fills the 14 i18n keys the first script found missing from the source-of-truth JSON across all 8 supported locales, closing the gap that caused raw key strings to leak into the dashboard.

  • Audit scripts: Key-reference audit uses the TypeScript compiler API (not regex) to extract t() call sites, classify them as client/server/dynamic, and diff against en-US JSON and the bundled fallback — producing both .json and .md reports. The hardcoded-string scanner heuristically finds un-localized JSX text and allowlisted attributes.
  • Locale additions: nav.noProgram and 13 app.admin.aiAdvisor.* keys (with interpolation placeholders {{description}}, {{source}}, {{count}}) are added to all 8 locales; pt-BR and pt-PT are correctly differentiated while es-ES and es-MX share identical values for these technical terms.
  • Verification: The parity test suite (228 pass / 9 skip) confirms all 8 locales now hold an identical key set; the committed audit reports serve as a reproducible pre-fix baseline.

Confidence Score: 5/5

Safe 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.

Important Files Changed

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]
Loading

Fix All in Claude Code

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

Comment thread scripts/audit-frontend-keys.mjs
Comment thread scripts/audit-hardcoded-strings.mjs Outdated
…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>
@haim-barad

Copy link
Copy Markdown
Member Author

@greptile review

@haim-barad haim-barad requested a review from edanBarad June 4, 2026 17:49

@edanBarad edanBarad left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@haim-barad haim-barad merged commit e6aacff into main Jun 4, 2026
7 checks passed
@haim-barad haim-barad deleted the feat/dashboard-i18n-audit branch June 4, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants