Uh oh!
There was an error while loading. Please reload this page.
feat(plugin-report): currency-aware, i18n labels in the dataset report renderer - #1830
Merged
Merged
Conversation
…t renderer Port the dashboard DatasetWidget fixes (PR #1825/#1827/#1828) to the standalone Reports renderer, which had the same user-visible problems: - Headers showed raw field names: DatasetReportTable rendered `{c}` and DatasetMatrixTable used a Title-Case humanize() — neither the real label. - Measures formatted as plain numbers with no currency awareness. - No i18n: "Total" and friends were hardcoded English. Changes: - useDatasetRows now captures the server-returned `fields` (label/format/ currency) and `object` (queryDataset already returns them). - Headers resolve via field label → i18n fieldLabel → raw name fallback (drops the `{c}`/humanizeDimension fallbacks). - Measure cells + server totals format with the field's currency (Intl symbol) and numeral format, mirroring DatasetWidget.formatMeasure — never a bare number or a misleading "$". - i18n via useObjectTranslation / useSafeFieldLabel with graceful fallback; "Total" uses tt('report.total', 'Total'). Drill-through and server-supplied totals are unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
Uh oh!
There was an error while loading. Please reload this page.
xuyushun441-sys added a commit
that referenced
this pull request
Jun 21, 2026
…ix binary-file NUL; register report.total (#1841) Follow-up cleanup to PR #1830. The dashboard `DatasetWidget` and the report `DatasetReportRenderer` had drifted into two copies of the same dataset-result formatting logic — which is exactly why the currency/label/i18n bug had to be fixed twice. This hoists the shared logic and removes a latent tooling hazard. core (@object-ui/core): - New utils/dataset-format.ts: `formatMeasure` (currency-aware), `formatDimensionValue`, `buildDatasetFieldHelpers` (field label → i18n fieldLabel → raw name), and the `DatasetResultField` type. Pure, no React/i18n (fieldLabel is injected). Unit-tested. i18n (@object-ui/i18n): - New `useSafeTranslate()` hook: per-call graceful `t(keyOrKeys, fallback)` with an ordered key-fallback chain — the inline pattern both renderers duplicated. - Register `report.total` in all 10 locale bundles (reusing each locale's existing dashboard total translation) so the report's "Total" is genuinely translatable, not just an English fallback. renderers: - `DatasetReportRenderer` and `DatasetWidget` now import the shared core/i18n helpers (net −235 lines of duplication). `PivotTable`'s two local graceful-translate helpers also fold into `useSafeTranslate`. - Fix the 2 literal NUL bytes in `DatasetReportRenderer` (the matrix bucket-key separator) that made the `.tsx` register as a BINARY file to grep/ripgrep/ editors — now a normal space (matching the dashboard's pivot separator). data-objectstack: - Widen `queryDataset`'s declared `fields` type to include `label`/`format`/ `currency` (it already ships them at runtime) so consumers stop re-declaring and casting. Tests: plugin-report 40 passed (+ positive i18n test: zh provider → 总计), plugin-dashboard 4031 passed, i18n 150 passed, core dataset-format 10 passed. type-check green across core/i18n/data-objectstack/plugin-report/plugin-dashboard. Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Ports the dashboard
DatasetWidgetreporting fixes (PR #1825 / #1827 / #1828) to the standalone Reports renderer (packages/plugin-report/src/DatasetReportRenderer.tsx), which had the same confirmed user-visible problems:DatasetReportTablerendered{c}(the dimension/measure name);DatasetMatrixTableused ahumanizeDimension()Title-Case helper, not the real label.formatCell()was plain number formatting, with nocurrency/Intland the wrong-symbol problem."Total"and friends were hardcoded English; nouseObjectTranslation/useSafeFieldLabel.useDatasetRowsdropped the server-returnedfields(label/format/currency) andobject, so there was nothing to render a real label from.The analytics server (
service-analytics, already merged) returns per-fieldlabel(dimensions and measures), measureformat,currency, andobjectin the dataset query result —queryDatasetalready surfaces them (packages/data-objectstack/src/index.ts).Changes
useDatasetRowsnow captures and returnsfieldsandobject.field label → i18n fieldLabel → raw name(drops the{c}andhumanizeDimensionfallbacks).humanizeDimensionis removed.formatMeasure(v, format, currency)mirroringDatasetWidget—Intlsymbol from the field's declaredcurrency, numeralformatfor grouping/decimals/percent, and no misleading$when there's no currency. Dimension cells keepformatCell.useObjectTranslation/useSafeFieldLabelwith graceful fallback (no provider → English default, never a raw key)."Total"→tt('report.total', 'Total').Tests
Extended
DatasetReportRenderer.test.tsx(vitest): label headers (flat + matrix, with raw-name fallback), currency formatting (no-currency = plain number, declared currency = Intl symbol, matrix cells + totals), and the i18nTotalEnglish fallback.pnpm --filter @object-ui/plugin-report exec vitest run→ 39 passed (4 files)npx turbo run type-check --filter=@object-ui/plugin-report→ green🤖 Generated with Claude Code