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>
pierreneter
left a comment
There was a problem hiding this comment.
Thanks, this round fixes what I asked for. I checked at 69171b3:
- The default table leaves
localeundefined, so dates follow the browser again. - Print, PDF and HTML export get the active texts.
- A bad tag (
de_DE,xx,'',i-klingon) falls back instead of throwing. localeis now the formatting tag, andLOCALES/LOCALE_NAMESare gone.- Count texts receive numbers, and German picks singular or plural.
DocViewerinherits an enclosing provider.- The comment counter no longer resets, and the helpers require their strings.
German stays out of index.js and the embed bundles. In the VM, unit tests (1207), typecheck, the build and the locale and embed browser suites (26) pass.
One small thing before merge:
src/react/xlsx/XlsxView.tsx:390-394: the four sheet-rename messages that came with v0.16 are still English literals: empty name, a name that already exists, more than 31 characters, characters that are not allowed. Withstrings={de}, renaming a tab to an existing name shows an English toast. They are not among the documented exceptions, and the PR description says the v0.16 labels are included. Four keys in thexlsxgroup, inenandde.
Non-blocking:
-
The default output is not quite "as before", which is what
docs/api.md:207says:- "1 word", "1 row × 1 col" (
main: "1 words"). - The 100,000-cell limit toasts are grouped by the browser ("100.000" in a de-DE browser).
- The sheet and hidden-sheet counts use the browser's digits.
- The zoom percent goes through
Intl, which can round an exact half differently fromMath.round.
The singular forms are an improvement, and I'm fine keeping all of these, but the docs should say so.
- "1 word", "1 row × 1 col" (
-
docs/api.md:15still passes an inlinestrings={{ file: { menu: 'Files' } }}, while the text below asks hosts to hoist it. With an inline object, every host render rebuilds the table: an open Document details dialog fetches its properties again and moves focus back to Close (DetailsDialog.tsx:25-35). Hoisting it in the example would match the advice. (The comment on that line is also two columns right of the ones above it.) -
Precedence: an outer
<StringsProvider locale="de-CH">with an innerstrings={de}formats asde-DE, because the inner table'slocalewins over the outer explicit tag.docs/api.md:236doesn't say which one wins. -
source.lines(n)returns only the word, andSourceEditor.tsx:71puts the number in front of it, so a language that needs the word first cannot do it. -
e2e/app/main.tsx:27: in the test app,?locale=de-DEselects the German table, which is the opposite of what the publiclocaleprop does now.
Hosts can translate the viewer or override individual labels through a typed
Stringstable covering the shared chrome, DOCX, XLSX, PPTX, Visio labels and viewer-generated export text. Partial overrides inherit from the enclosing provider or English. Status callbacks receive numeric counts for pluralization.English is the default bundle. Import standard German explicitly from
@p10node/office-engine/locales/deand pass it asstrings. Thelocaleprop sets BCP 47 number and date formatting. Malformed tags fall through to the table or browser defaults. Without an override, dates and grouped counts retain browser formatting and measurements retain their existing ASCII form. The API guide includes US and British English examples.This is the first layer in #6 → #7 → #8 → #9. It includes both the v0.16.0 editor labels and the v0.17.0 spreadsheet release. The localization guide covers the public API, exceptions and export behavior.