Skip to content

fix(editor): a missing translation must not become a document error - #194

Merged
chaxus merged 1 commit into
mainfrom
fix-locale-hint-crash
Aug 23, 2026
Merged

fix(editor): a missing translation must not become a document error#194
chaxus merged 1 commit into
mainfrom
fix-locale-hint-crash

Conversation

@chaxus

@chaxus chaxus commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Reported in Korean: opening a blank document showed the vendor's modal "An error occurred while working with the document. Use the 'Download as' option to save a backup copy" — before typing anything. Reproduced in a production build; only ko, and every time.

Cause

DE.Views.Statusbar.tipMultiplePages is in en.json and not in ko.json, and unlike most strings it has no default in the component's own source — so the property is undefined. The status bar hands it to a tooltip setter that does not check:

updateHint: function (t) { ... "string" == typeof t ? t : t[0] ... }

undefined[0] throws inside the view layer, the app catches it as a document error, and the user is told to save a backup of a document they have not written yet.

This is not one bad file: all 44 non-English locales are short against en.json, from 1 key to 3167. Korean simply lost the lottery of which gap reaches a tooltip setter.

app zh ja ko de es pt
documenteditor 17 16 22 1 1 16
spreadsheeteditor 0 552 50 0 25 0
presentationeditor 0 305 0 0 0 0
pdfeditor 71 36 72 36 36 36

Two defences

  1. bin/locale-fill.mjs backfills, from en.json, every key missing in the locales this site is translated into — 17 files, ~113 KB, keeping the vendor's minified formatting (pretty-printing would have added ~25 KB per file to a 600 MB tree). bin/build.sh runs it before the vendor tree is hashed into VENDOR_VERSION, and test/unit/vendor-locale.test.ts fails when it has not been run — which is exactly what the next vendor upgrade will do.
  2. Guard 11 (guards/hint-fallback.ts) makes updateHint(undefined) a no-op. That covers the other 38 locales, which ?locale= can still select, and whatever the next upgrade breaks.

An English tooltip is a blemish. A modal error on an empty document is someone deciding this editor cannot be trusted with their file.

Test

test/e2e/editor-locales.spec.ts opens a blank document in each of the six non-English site languages and fails on a vendor dialog. Nothing in the suite covered this, because everything else opens the editor in English.

Reverse-checked both defences separately:

  • key removed and guard disabled → the ko case fails with the reported dialog
  • key removed, guard in place → passes

🤖 Generated with Claude Code

Reported in Korean: opening a blank document showed the vendor's modal
"An error occurred while working with the document. Use the 'Download
as' option to save a backup copy" -- before typing anything. Reproduced
in a production build; only ko, and every time.

The cause is a translation gap. `DE.Views.Statusbar.tipMultiplePages` is
in en.json and not in ko.json, and unlike most strings it has no default
in the component's own source, so the property is `undefined`. The status
bar passes it to a tooltip setter that does not check:

    updateHint: function (t) { ... "string" == typeof t ? t : t[0] ... }

`undefined[0]` throws inside the view layer, the app catches it as a
document error, and the user gets a modal telling them to save a backup
of a document they have not written yet.

This is not one bad file: all 44 non-English locales are short against
en.json, from 1 key to 3167. Korean simply lost the lottery of which gap
reaches a tooltip setter. So there are two defences:

1. bin/locale-fill.mjs backfills, from en.json, every key missing in the
   locales this site is translated into -- 17 files, ~113 KB, keeping the
   vendor's minified formatting so the tree does not grow by 25 KB a file.
   bin/build.sh runs it before the vendor tree is hashed into
   VENDOR_VERSION, and test/unit/vendor-locale.test.ts fails when it has
   not been run (which is what a vendor upgrade will do).
2. Guard 11 (guards/hint-fallback.ts) makes `updateHint(undefined)` a
   no-op. That covers the other 38 locales, which `?locale=` can still
   select, and whatever the next upgrade breaks.

An English tooltip is a blemish. A modal error on an empty document is
someone deciding this editor cannot be trusted with their file.

test/e2e/editor-locales.spec.ts opens a blank document in each of the six
non-English site languages and fails on a vendor dialog -- nothing in the
suite covered this, because everything else opens the editor in English.
Reverse-checked both defences: with the key removed and the guard
disabled the ko case fails with the reported dialog; with the key removed
and the guard in place it passes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@chaxus
chaxus enabled auto-merge (rebase) August 23, 2026 03:32
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying document with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4ae7204
Status: ✅  Deploy successful!
Preview URL: https://33f6ac5b.document-7hm.pages.dev
Branch Preview URL: https://fix-locale-hint-crash.document-7hm.pages.dev

View logs

@chaxus
chaxus merged commit ca134f6 into main Aug 23, 2026
31 of 33 checks passed
@chaxus
chaxus deleted the fix-locale-hint-crash branch August 23, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant