Repository navigation
Conversation
pierreneter
left a comment
There was a problem hiding this comment.
Thanks for this, the typed table and the parity test are a good base.
Not ready on its own yet. Merged alone it ships a half-translated viewer and docs ahead of the code:
- With
locale="de"only the top bar and the shared dialogs are German. The File menu is still the literal"File"(src/react/file/FileMenu.tsx:186), and the toolbars, context menus, find bar and status line stay English. 130 of the 219 keys are read by nothing at this commit. README.mdanddocs/api.mdsay every text comes from the table, and the examples usedocx.statusandxlsx.addSheet, which only exist inStringsfrom #8 on. Thefile: { menu }example has no effect here.
Either of these would do:
- Move the three
feat(docx|xlsx|pptx): ... read their texts from the strings tablecommits from #8 into this PR (my preference: one PR, one complete feature), or - Limit the docs and examples here to what this PR converts.
Smaller points: de is always bundled (about 2.9 KB gzip), which is fine for now. The table is Swiss German with de-CH number grouping; please name that in the docs, since locale="de-DE" falls back to English without a word. A test that renders one component in German would be good.
I also fixed unsafe fallback for unknown locale names, stale comment translations after switching languages, untranslated PPTX comment locations, and repeated web-component load events after UI updates. Verification: 549 unit tests, 15 localization/embed browser tests, typecheck, build and package checks pass locally. Verified that default viewer and embed bundles exclude German. Current Locale-aware numeric input is tracked separately in #17. |
pierreneter
left a comment
There was a problem hiding this comment.
Thanks, the earlier points are done: every key has a reader now, the docs examples match the table, German is an opt-in import with standard spelling, and there are rendered tests in German.
Before merge (line numbers are at acd8b16):
src/react/strings/en.ts:7: the default table setslocale: 'en-US', and dates and counts are now formatted with it. Before, they usedtoLocaleString()with the browser's locale. So for every host that passes nothing, avi-VNoren-GBbrowser now shows 5 March as3/5/2026, 2:00:00 PMin Document details, comment times and tracked-change tooltips. The default output should stay as it was; leaving the default table'slocaleundefined, soIntltakes the browser's, would do it.- Rebase onto
main. v0.14.0 added Visio, and this now conflicts indocs/api.md,src/react/DocViewer.tsxandsrc/react/file/importFile.ts. The table needs afrom.visiotext, andfile.unsupportedshould name Visio, in bothenandde. src/react/file/print.tsx:182: print, PDF and HTML export render the pages in their owncreateRootwith noStringsProvider, souseStrings()gives English there. German UI, a slide with an EMF picture:EMF-Bildon screen,EMF imagein the export.src/react/strings/index.tsx:41:strings.localegoes straight intoIntl.NumberFormatduring render. A host that passes its app locale asde_DEgets aRangeErrorand a blank viewer. Please validate the tag once and fall back, rather than throw.
Worth settling now, since these become API:
- The
localeprop and attribute,LOCALESandLOCALE_NAMES: the only valid value is the default. Anything else,de-DEincluded, is silently English, and it does not select the formats either (that isstrings.locale). Either droplocale, or make it the BCP 47 formatting tag that defaults to the browser's. The second also solves 1. - Count texts receive strings that are already formatted (
docx.status,xlsx.status,usedRangeValue,hiddenSheets,pptx.status), so a table cannot choose a plural form: the German one shows1 Wörterand1 Zeilen × 1 Spalten. Passing the numbers keeps that open. Changing the signature after a release breaks host overrides. src/react/DocViewer.tsx:140:DocVieweralways mounts its ownStringsProviderbuilt from English, so an enclosing<StringsProvider strings={de}>is ignored.IconsProvidercomposes with the outer one; this should too.
Non-blocking:
src/react/xlsx/XlsxView.tsx:312: the comment-host effect now depends onstr, and its local counter starts again when the strings object changes identity (an inlinestrings={{...}}does that on every host render). The next "go to comment" on the same sheet can then reuse agoto.nthe grid has already seen and do nothing. Reading the hint lazily from the comments controller would takestrout of those three effects (DocxView.tsx:723,XlsxView.tsx:358,PptxView.tsx:636).- The provider memoises on object identity, and every docs example passes an inline object, so each host render rebuilds the table and re-renders every consumer. A content key (as
useCollabdoes withoptsKey) or a hoisted object in the examples. - Main-thread error texts stay English (
HTTP 404 while fetching …,Document is still syncing) and are not among the documented exceptions. - Helpers default their strings argument to English (
styleChoices(…, t = en),sheetPrintable(…, t = en)), so a call site that forgets it compiles and renders English. Required parameters would catch that. - The PR description still says
'en' | 'de', Swiss spelling, and that the DOCX / XLSX / PPTX views follow in later PRs. docs/api.md:66: the newlocalerow is out of line with the table's columns.
|
Addressed the localization follow-ups:
Updated the docs and description, including the small count-formatting and exact-half zoom-rounding differences. Build, typecheck, browser/export and packed-package checks pass locally. Upstream integration note: this candidate was reviewed and tested against |
The texts upstream added meanwhile go through the strings table, in English and German: Duplicate sheet (now a real copy of the sheet), the custom number format picker, the fill and merged-paste limits, the message after a merge drops values, the cell field's label, and the unsupported-file error saying what the file is instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hosts can translate the viewer or override individual labels without forking its components. A typed
Stringstable covers the shared chrome and dialogs, DOCX/XLSX/PPTX views, comments, drawing placeholders, collaboration labels and Visio import labels. Partial overrides inherit an enclosingStringsProvideror English. Print, PDF and HTML export carry the same table into their separate React roots.English is the only default language bundled. Standard German is an explicit package import using
de-DEformatting:localeis an optional BCP 47 number/date formatting tag; it does not choose or load UI translations. Without an override, dates and grouped counts retain browser formatting; page/slide numbers and measurements retain ASCII digits and decimal points. The prop takes precedence overstrings.locale, and malformed tags fall through to a valid table/inherited tag safely. Count callbacks receive numbers for pluralization and an optional final formatting tag. The API docs show hoisted partial overrides, custom tables and US/British English variants.Reconstructed on main
fb718881, preserving its security, save and Visio changes. German UI labels survive export; changing strings no longer resets spreadsheet comment navigation.Validation includes a frozen Bun1.4.4 install, typecheck, production/companion builds and package checks. The correction passes710 unit tests,24 source/embed/production browser checks, and11 repeated packed-package browser checks. Earlier coverage also exercised49 source-browser cases. Independent Claude Opus5.5 high review approved the corrected candidate after build/runtime/package verification. Browser checks include default/invalid locales, provider inheritance, live switching, singular/numeric callbacks, Visio and separate print/export roots; downloaded HTML was reopened and PDF text inspected. Native OS print-dialog interaction and the entire unrelated browser suite were not tested. Core/transport diagnostic errors and locale-aware numeric-input parsing remain documented exceptions/separate work.
Display notes: Sheets/hidden-sheet counts and both paste-limit counts now use the same locale formatting as other grouped counts. Intl percent formatting can round an exact half differently from Math.round (for example0.285); preset zoom values are unaffected.
Upstream integration note: this candidate was reviewed and tested against
fb718881(v0.15.0). Since that validation,mainadvanced to4a78390(v0.16.0), with overlapping editor changes. This push publishes the reviewed fixes; resolving the new merge conflicts and validating that integration are still pending.