diff --git a/docs/concepts/views.md b/docs/concepts/views.md index 8d1ca0cd2..446f5f766 100644 --- a/docs/concepts/views.md +++ b/docs/concepts/views.md @@ -114,8 +114,8 @@ pivotkit-core has these functions for it: probably meant (`params.suggestion`). - The JSON Schema `pivotkit-core/schema/view-2.json` checks a view that a program or an LLM wrote, before it reaches the data. The schema is built from the engine's tables. -- `describeView(view, data)` explains a view: its parts, with one short English text each - ([reference](../reference/core.md#describing-data-and-views)). +- `describeView(view, data)` explains a view: its parts, with one short text each, in English or + German ([reference](../reference/core.md#describing-data-and-views)). The UI normalizes every view it gets. It shows what it dropped as a warning above the result, in plain words ([what people see](../use/behaviour.md#parts-of-a-view-that-were-not-used)). diff --git a/docs/reference/core.md b/docs/reference/core.md index 93fe0b1d7..bdee726a1 100644 --- a/docs/reference/core.md +++ b/docs/reference/core.md @@ -184,14 +184,13 @@ pivotkit-core ships it as `pivotkit-core/schema/view-2.json`, and the site publi ### Describing data and views -Plain, structured summaries for a log, an approver or an LLM that writes or explains views. They are -JSON with one short English `text` per part, without a locale, and nothing rendered. Values from the -data are data, and a prompt should mark them as such. +Plain, structured summaries for a log, an approver or an LLM that writes or explains views: JSON with +one short `text` per part, nothing rendered. Values from the data are data; a prompt should mark them as such. | Function | Returns | What | | --- | --- | --- | | `describeSource(data, { items })` | `{ rows, fields, text }` | Per field: `name`, `type`, and the `aggregators` and filter types (`filters`) that work on it. Encoded data adds `distinct`, `blanks`, the first `items` and `min`/`max` of numbers and dates (dates as ISO days). `items` holds at most `DESCRIBE_LIMITS.items`, 20, each cut at 80 characters. A schema `{ fields }` or a fields array gives the types only (`rows: null`). Rows that are not encoded throw `INVALID_ARGUMENT`, so `encode()` them first. Field names in the `text`s are cut at 80 characters, as items are. | -| `describeView(view, schema, { limits })` | object | The view as `normalize` reads it, in parts: `rows`, `cols`, `values` with their names, `filters`, `derived`, `sort` and `display`. Each normalized filter has its `text`: `Region is one of "North", "South" (blanks dropped)`. It adds `valid`, `errors` and `warnings` of `validate`, and `text`, the whole view in one sentence. A part with an error is left out of the parts. The `text` of an invalid view starts with `(invalid: n errors, the parts they name are left out)`. | +| `describeView(view, schema, { limits, labels, locale })` | object | The view as `normalize` reads it, in parts: `rows`, `cols`, `values` with their names, `filters`, `derived`, `sort` and `display`. Each normalized filter has its `text`: `Region is one of "North", "South" (blanks dropped)`. It adds `valid`, `errors` and `warnings` of `validate`, and `text`, the whole view in one sentence. A part with an error is left out of the parts. The `text` of an invalid view starts with `(invalid: n errors, the parts they name are left out)`. `labels` are the words of the texts, English by default ([`DESCRIBE_LABELS`](#helpers)): German writes `Region ist einer der Werte „North“; „South“, ohne leere Werte`: a list's items by "; " and filters by "; und ", as German numbers have a decimal comma. A key or a table entry that `labels` leaves out stays English, at any depth. `labels` that are not an object, or that hold a key `DESCRIBE_LABELS` does not have or a word of the wrong kind (a number for a text, a text for a table, a `lang` that is no language), throw `INVALID_OPTION`. `locale` writes the numbers of filter values as the locale does, without grouping (`1,5` and `2025` for `de-DE`); without it they are as in JSON. Dates stay ISO days. The `errors` and `warnings` stay English. | ### A view from field names { #view-from-field-names } @@ -633,6 +632,7 @@ files contain and where Excel's number formats cannot follow the grid. | `closest(name, candidates)` | "Did you mean": the name of `candidates` closest to `name` as `foldText` folds both, else `null`. The edit distance is at most a third of the name's length, at least 1 and at most 3. A swap of two neighbours is one edit. `HINT_LIMITS` (`{ candidates: 1000, length: 64, distance: 3 }`) bounds it, so a hint costs a few thousand steps per name at most. The view's hints, pivotkit-report's template check and pivotkit-cli's options use it. | | `DEFAULT_LABELS` | The texts the engine writes (blank, totals, value names, aggregator names, "show as" names), to override per call with `labels`. | | `REPORT_LABELS`, `reportLabels(locale)` | The same texts as a report shows them, per language. `en` has yes/no as words and the aggregators' longer names ("Distinct count"). `de` has "Gesamtergebnis" and "Summe von Units". `reportLabels` gives a locale's texts: German for `"de-DE"`, English for any other. pivotkit-react's report and pivotkit-report use them. | +| `DESCRIBE_LABELS`, `describeLabels(locale, own)` | The words of `describeView`, English and German. `describeLabels` gives a locale's words: German for `"de-DE"`, English for any other. `own` words go over them at any depth; words that name their language (`lang`) go over that language's. `own` that is not an object, or with a key or a word `describeView` refuses, throws `INVALID_ARGUMENT`. The result is a frozen copy. A table of forms by count (`top`, `invalid`, a range's forms) takes every plural category of its `lang` (`few`, `many`). `and` joins the filters in `describeView`'s `text` ("; and ", German "; und "); `filterList` joins a list of the filters alone, as the HTML report's `{{filters}}` does ("; ", German "; und ", as German lists use "; "). German names one whole unit of a relative range as the engine keeps it: "heute", "gestern", "im Vorjahr", and from an anchor "am Tag davor". pivotkit-report's HTML report uses them for its filters and its summary. | | `ROW_COUNT_TEXTS` | The row count in words, English and German, with one form per plural category: `rowsCount` ("8 rows") and `rowsFiltered` ("6 of 8 rows") for when filters leave rows out. pivotkit-react's line under the result and pivotkit-report's HTML report both use them. | | `pluralForm(forms, count, lang)`, `PLURAL_CATEGORIES` | The form of a count's words for `count` in the language `lang`, after `Intl.PluralRules`: `forms[category]`, else `forms.other`. `PLURAL_CATEGORIES` lists the categories a count's forms may have. pivotkit-react's labels and pivotkit-report's texts use them. | | `numberRepeats(names)` | The names with each one that comes again numbered, case-insensitively: `["Sum of A", "sum of a"]` gives `["Sum of A", "sum of a (2)"]`. The grid, the chart's series and pivotkit-react's chips name a value that is in the view twice this way. | diff --git a/docs/reference/localisation.md b/docs/reference/localisation.md index 8e8b74550..66153aafc 100644 --- a/docs/reference/localisation.md +++ b/docs/reference/localisation.md @@ -46,6 +46,9 @@ console which key holds that text now. The report's `lang` attribute follows the labels, so screen readers use the right voice. +The HTML report of [pivotkit-report](report.md) writes its filters and its summary in the locale's +language too, with the locale's numbers ([`describeLabels`](report.md#options)). + The web component loads the German texts of the first render as a file of its own: - Only a German report loads it, before it renders. Until then the report shows its skeleton without diff --git a/docs/reference/print-template.md b/docs/reference/print-template.md index eeab12a27..1d5a2256b 100644 --- a/docs/reference/print-template.md +++ b/docs/reference/print-template.md @@ -40,8 +40,8 @@ A source's own template wins over `output.template`. Without either, the built-i | `{{generated}}` | text | When it was made, in the locale and time zone ("Nov 13, 2026, 10:00 AM"; fixed with `now`). | | `{{dataAsOf}}` | text | When the data is from, in the locale and time zone with the zone named ("Nov 15, 2026, 8:00 AM UTC"), from `dataAsOf`; empty without it. The REST service and the MCP server pass it. | | `{{rows}}` | text | The data's rows ("8 rows"). When the filters leave rows out, the rows they keep of them ("6 of 8 rows"). Empty where the policy withholds the row count (`rows: false`). | -| `{{filters}}` | text | The view's filters in words, or "None". | -| `{{summary}}` | text | The view in one sentence ("sum of Units by Region"). | +| `{{filters}}` | text | The view's filters in words, or "None", in the report's language. | +| `{{summary}}` | text | The view in one sentence, in the report's language ("sum of Units by Region", "Summe von Units nach Region"). | | `{{lang}}`, `{{dir}}` | text | The locale ("de-DE") and its direction (`ltr`, `rtl`). | | `{{style}}` | markup | The report's `