Skip to content

fix: gracefully handle missing translation files#364

Open
dcalhoun wants to merge 1 commit intotrunkfrom
fix/mitigate-missing-translation-errors
Open

fix: gracefully handle missing translation files#364
dcalhoun wants to merge 1 commit intotrunkfrom
fix/mitigate-missing-translation-errors

Conversation

@dcalhoun
Copy link
Member

What?

Ensure the editor does not fail to load when translation files are missing.

Why?

If the src/translations/ directory does not exist — for example, after setting up a new git worktree without running make prep-translations — the Vite dev server fails its dependency scan because the dynamic import in localization.js cannot resolve any translation files. This blocks the editor from loading entirely.

How?

  • Add a .gitkeep to src/translations/ so the directory is always present in a fresh clone, giving Vite's dependency scanner something to resolve against.
  • Update .gitignore to ignore translation file contents but preserve the .gitkeep.
  • Downgrade the translation load failure from error to warn with a user-friendly message, since this is a recoverable situation that gracefully falls back to English.

Testing Instructions

  1. Clone the repository fresh (or set up a new worktree).
  2. Run make dev-server-force (ensures Vite does not reuse caches).
  3. Verify the following error is not present in the terminal output:
Previously observed error
  VITE v7.3.1  ready in 575 ms

  ➜  Local:   http://localhost:5174/
  ➜  Network: http://192.168.0.167:5174/
  ➜  press h + enter to show help
(!) Failed to run dependency scan. Skipping dependency pre-bundling. Error:   Failed to scan for dependencies from entries:
  /Users/[REDACTED]/Sites/a8c/GutenbergKit--test/src/index.html

  ✘ [ERROR] Could not resolve import("../translations/**/*.json")

    src/utils/localization.js:39:3:
      39 │       `../translations/${ locale }.json`
         ╵       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


    at failureErrorWithLog (/Users/[REDACTED]/Sites/a8c/GutenbergKit--test/node_modules/esbuild/lib/main.js:1467:15)
    at /Users/[REDACTED]/Sites/a8c/GutenbergKit--test/node_modules/esbuild/lib/main.js:926:25
    at runOnEndCallbacks (/Users/[REDACTED]/Sites/a8c/GutenbergKit--test/node_modules/esbuild/lib/main.js:1307:45)
    at buildResponseToResult (/Users/[REDACTED]/Sites/a8c/GutenbergKit--test/node_modules/esbuild/lib/main.js:924:7)
    at /Users/[REDACTED]/Sites/a8c/GutenbergKit--test/node_modules/esbuild/lib/main.js:936:9
    at new Promise (<anonymous>)
    at requestCallbacks.on-end (/Users/[REDACTED]/Sites/a8c/GutenbergKit--test/node_modules/esbuild/lib/main.js:935:54)
    at handleRequest (/Users/[REDACTED]/Sites/a8c/GutenbergKit--test/node_modules/esbuild/lib/main.js:628:17)
    at handleIncomingPacket (/Users/[REDACTED]/Sites/a8c/GutenbergKit--test/node_modules/esbuild/lib/main.js:653:7)
    at Socket.readFromStdout (/Users/[REDACTED]/Sites/a8c/GutenbergKit--test/node_modules/esbuild/lib/main.js:581:7)

Accessibility Testing Instructions

Not applicable — no UI changes.

Persist the `src/translations/` directory via `.gitkeep` so the Vite
build does not fail when translation files have not been fetched. Also
downgrade the translation load error from `error` to `warn` with a
user-friendly message, since this is a recoverable situation that falls
back to English.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dcalhoun dcalhoun added the [Type] Bug An existing feature does not function as intended label Mar 10, 2026
@dcalhoun dcalhoun marked this pull request as ready for review March 10, 2026 18:21
@dcalhoun dcalhoun requested a review from adalpari March 10, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant