From 890845d78e83c6b8e54a1548992bb98197ae374b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Wed, 25 Nov 2026 16:44:16 +0100 Subject: [PATCH 01/20] feat(core): describeView writes its texts in German too - describeView(view, schema, { labels }) takes the words of its texts. DESCRIBE_LABELS holds English and German as whole phrases with placeholders, so each language keeps its word order; describeLabels(locale) picks one. A key that labels leave out stays English. - German takes the aggregator names from REPORT_LABELS and the grouping units from GROUPING_NAMES. - Each phrase is built from the words first and filled once with the view's names and values, so a name that looks like a placeholder stays as it is. - English is unchanged, word for word: the MCP server and the CLI keep it. Refs #798 Co-Authored-By: Claude Opus 5.5 --- docs/concepts/views.md | 4 +- docs/reference/core.md | 6 +- packages/pivotkit-core/AGENTS.md | 1 + packages/pivotkit-core/CHANGELOG.md | 5 + packages/pivotkit-core/src/describe-labels.js | 232 ++++++++++++++++++ packages/pivotkit-core/src/describe.js | 113 +++++---- packages/pivotkit-core/src/index.js | 2 + packages/pivotkit-core/test/api.test.js | 4 +- packages/pivotkit-core/test/describe.test.js | 48 +++- packages/pivotkit-core/test/types/consumer.ts | 5 +- scripts/growth-baseline.json | 3 +- 11 files changed, 370 insertions(+), 53 deletions(-) create mode 100644 packages/pivotkit-core/src/describe-labels.js 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 d43ef32e9..9a4ce2230 100644 --- a/docs/reference/core.md +++ b/docs/reference/core.md @@ -185,13 +185,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. +JSON with one short `text` per part, without a locale, and nothing rendered. The texts are English; +`describeView` also writes German. Values from the data are data, and 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 })` | 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.de` or `describeLabels("de-DE")` writes `Region ist einer der Werte "North", "South" (ohne leere Werte)`. A key `labels` leaves out stays English. The `errors` and `warnings` stay English. | ### A view from field names { #view-from-field-names } diff --git a/packages/pivotkit-core/AGENTS.md b/packages/pivotkit-core/AGENTS.md index b2453735d..51aeeaa06 100644 --- a/packages/pivotkit-core/AGENTS.md +++ b/packages/pivotkit-core/AGENTS.md @@ -77,6 +77,7 @@ Reuse these instead of writing a second version: | Every place a view names a field | `mapFieldRefs` in `view-file.js` | | A loaded file's source id | `sourceIdOf` in `source-id.js` | | Grouping names and report words, en and de | `GROUPING_NAMES`, `REPORT_LABELS` in `labels.js` | +| describeView's words, en and de | `DESCRIBE_LABELS` in `describe-labels.js` | | Chart data and the type "auto" stands for | `toSeries`, `autoChartType` in `chart-series.js` | | The ECharts option, loaded with the chart | `toEChartsOption` in `chart.js`, also exported by `chart-style.js` | | Chart marks for screen, SVG and print | `decorateOption` in `chart-style.js` | diff --git a/packages/pivotkit-core/CHANGELOG.md b/packages/pivotkit-core/CHANGELOG.md index 9918cb65b..20d58ee7b 100644 --- a/packages/pivotkit-core/CHANGELOG.md +++ b/packages/pivotkit-core/CHANGELOG.md @@ -6,6 +6,11 @@ All notable changes to `pivotkit-core` are documented in this file. The format i ## [Unreleased] +### Added + +- `describeView(view, schema, { labels })` writes its texts in German too: `DESCRIBE_LABELS.de`, or + `describeLabels(locale)` for a locale's language. English stays the default, word for word. + ## [0.10.0] - 2026-11-24 ### Fixed diff --git a/packages/pivotkit-core/src/describe-labels.js b/packages/pivotkit-core/src/describe-labels.js new file mode 100644 index 000000000..d42e91a0c --- /dev/null +++ b/packages/pivotkit-core/src/describe-labels.js @@ -0,0 +1,232 @@ +/* + * The words of describeView in English and German: whole phrases with {placeholders}, so each + * language keeps its own word order. pivotkit-report's HTML report writes its filters and its + * summary with the words of its language; the MCP server and the CLI keep English. + */ + +import { GROUPING_NAMES, REPORT_LABELS } from "./labels.js"; + +/** @typedef {Readonly<{ yes: string, not: string }>} Phrase a phrase, and the phrase with "not" */ +/** @typedef {Readonly<{ one: string, other: string }>} Counted a phrase by Intl.PluralRules category of {count} */ +/** + * @typedef {object} Ranges the relative ranges: "last 3 years", "this year" + * @property {Readonly>} last + * @property {Readonly>} next + * @property {Readonly>} before + * @property {Readonly>} this + */ + +/** + * @typedef {object} DescribeLabels the words of describeView; {placeholders} are filled once, with the view's names and values + * @property {string} lang the language whose plural rules pick a Counted form + * @property {Readonly> | null} aggregators an aggregator's name; null: its key ("sum") + * @property {string} valueName a value: "{agg} of {field}" + * @property {string} valueOfRows a value of no field: "{agg} of rows" + * @property {string} firstValue what a filter or sort goes by when it names no value + * @property {string} countRows what a view without values shows + * @property {string} more a list that is cut: "{items} and {count} more" + * @property {string} noItems + * @property {Readonly>} blanks + * @property {string} withBlanks "{text} ({blanks})" + * @property {Phrase} in "{field} is one of {items}" + * @property {Phrase} blank + * @property {string} asShown a text filter on labels: "{field} (as shown)" + * @property {Readonly>} text + * @property {string} match "{text}, case {case}, whitespace {whitespace}" + * @property {Readonly>} cases + * @property {Readonly>} whitespace + * @property {Phrase} compare "{field} is {op}"; {op} is one of `ops` + * @property {Readonly>} ops a comparison with {value} (and {value2}) + * @property {string} precision "{text} (by {precision})" + * @property {Readonly>} precisions + * @property {Phrase} relative "{field} is in the {range}" + * @property {Ranges} ranges a relative range by direction and unit + * @property {string} how "{text} ({how})": how a relative range is counted + * @property {string} rolling + * @property {string} currentExcluded + * @property {string} fromAnchor "from {anchor}" + * @property {Readonly>} anchors "latest" and "first"; a date anchor stays as it is + * @property {string} top "top {count} {field} by {by}" + * @property {string} bottom + * @property {string} tiesKept "{text}, ties kept" + * @property {Phrase} value "{field} where {by} is {op}" + * @property {Readonly> | null} units a grouping's unit; null: its key ("yearMonth") + * @property {string} derived "{name}: {field} by {by}" + * @property {string} bins "{name}: {field} by {by} of {size}" + * @property {string} sortLabel "{field} by label, {order}" + * @property {string} sortValue "{field} by {by}, {order}" + * @property {string} sortColumn "{field} by {by} in the column {column}, {order}" + * @property {string} sortCustom "{field} in a custom order, {order}" + * @property {Readonly>} orders + * @property {string} rows "by {fields}" + * @property {string} cols "across {fields}" + * @property {string} where "where {filters}" + * @property {string} and between two filters + * @property {string} chart "as a {type}": {type} is one of `chartTypes` + * @property {string} both "as a table and a {type}" + * @property {Readonly>} chartTypes by CHART_TYPES; "auto" is a chart of no named type + * @property {Counted} invalid "(invalid: {count} errors, the parts they name are left out)" + */ + +const DATE_UNITS = Object.freeze(["hour", "day", "week", "month", "quarter", "year"]); + +/** The English ranges: "last 3 years", "this year". */ +const enRanges = (word) => Object.freeze(Object.fromEntries(DATE_UNITS.map((u) => [u, Object.freeze({ one: `${word} {count} ${u}`, other: `${word} {count} ${u}s` })]))); + +/** + * The German ranges, from each unit's grammar: the preposition with its article before "letzten" + * ("im letzten Jahr"), the article after "vor" ("vor dem letzten Jahr"), the plural in the dative + * and "this" as a whole phrase. + */ +const DE_UNITS = Object.freeze({ + hour: { at: "in der", before: "vor der", one: "Stunde", other: "Stunden", this: "in dieser Stunde" }, + day: { at: "am", before: "vor dem", one: "Tag", other: "Tagen", this: "am heutigen Tag" }, + week: { at: "in der", before: "vor der", one: "Woche", other: "Wochen", this: "in dieser Woche" }, + month: { at: "im", before: "vor dem", one: "Monat", other: "Monaten", this: "in diesem Monat" }, + quarter: { at: "im", before: "vor dem", one: "Quartal", other: "Quartalen", this: "in diesem Quartal" }, + year: { at: "im", before: "vor dem", one: "Jahr", other: "Jahren", this: "in diesem Jahr" } +}); +const deRanges = (word, before) => Object.freeze(Object.fromEntries(DATE_UNITS.map((u) => { + const g = DE_UNITS[u]; + return [u, Object.freeze({ one: `${before ? g.before : g.at} ${word} ${g.one}`, other: `${before ? "vor den" : "in den"} ${word} {count} ${g.other}` })]; +}))); + +const phrase = (yes, not) => Object.freeze({ yes, not }); + +/** + * The words of describeView, English and German. English names aggregators, units, precisions and + * chart types by their keys, as a view does; German takes the aggregators' names from + * REPORT_LABELS and the grouping units from GROUPING_NAMES. + * @type {Readonly>>} + */ +export const DESCRIBE_LABELS = Object.freeze({ + en: Object.freeze({ + lang: "en", + aggregators: null, + valueName: "{agg} of {field}", + valueOfRows: "{agg} of rows", + firstValue: "the first value", + countRows: "count of rows", + more: "{items} and {count} more", + noItems: "(no items)", + blanks: Object.freeze({ exclude: "blanks dropped", include: "blanks kept", only: "only blanks" }), + withBlanks: "{text} ({blanks})", + in: phrase("{field} is one of {items}", "{field} is not one of {items}"), + blank: phrase("{field} is blank", "{field} is not blank"), + asShown: "{field} (as shown)", + text: Object.freeze({ + equals: phrase("{field} equals {value}", "{field} does not equal {value}"), + contains: phrase("{field} contains {value}", "{field} does not contain {value}"), + beginsWith: phrase("{field} begins with {value}", "{field} does not begin with {value}"), + endsWith: phrase("{field} ends with {value}", "{field} does not end with {value}") + }), + match: "{text}, case {case}, whitespace {whitespace}", + cases: Object.freeze({ insensitive: "insensitive", sensitive: "sensitive" }), + whitespace: Object.freeze({ collapse: "collapse", exact: "exact" }), + compare: phrase("{field} is {op}", "{field} is not {op}"), + ops: Object.freeze({ "=": "{value}", ">": "greater than {value}", ">=": "at least {value}", "<": "less than {value}", "<=": "at most {value}", between: "between {value} and {value2}" }), + precision: "{text} (by {precision})", + precisions: Object.freeze({ year: "year", quarter: "quarter", month: "month", day: "day", hour: "hour" }), + relative: phrase("{field} is in the {range}", "{field} is not in the {range}"), + ranges: Object.freeze({ + last: enRanges("last"), + next: enRanges("next"), + before: enRanges("before"), + this: Object.freeze(Object.fromEntries(DATE_UNITS.map((u) => [u, `this ${u}`]))) + }), + how: "{text} ({how})", + rolling: "rolling", + currentExcluded: "current excluded", + fromAnchor: "from {anchor}", + anchors: Object.freeze({ latest: "latest", first: "first" }), + top: "top {count} {field} by {by}", + bottom: "bottom {count} {field} by {by}", + tiesKept: "{text}, ties kept", + value: phrase("{field} where {by} is {op}", "{field} where {by} is not {op}"), + units: null, + derived: "{name}: {field} by {by}", + bins: "{name}: {field} by {by} of {size}", + sortLabel: "{field} by label, {order}", + sortValue: "{field} by {by}, {order}", + sortColumn: "{field} by {by} in the column {column}, {order}", + sortCustom: "{field} in a custom order, {order}", + orders: Object.freeze({ asc: "ascending", desc: "descending" }), + rows: "by {fields}", + cols: "across {fields}", + where: "where {filters}", + and: "; and ", + chart: "as a {type}", + both: "as a table and a {type}", + chartTypes: Object.freeze({ auto: "chart", bar: "bar chart", line: "line chart", area: "area chart", pie: "pie chart", donut: "donut chart", heatmap: "heatmap chart", combo: "combo chart", treemap: "treemap chart" }), + invalid: Object.freeze({ one: "(invalid: {count} error, the parts they name are left out)", other: "(invalid: {count} errors, the parts they name are left out)" }) + }), + de: Object.freeze({ + lang: "de", + aggregators: REPORT_LABELS.de.aggregators, + valueName: REPORT_LABELS.de.valueName, + valueOfRows: "{agg} der Zeilen", + firstValue: "der erste Wert", + countRows: "Anzahl der Zeilen", + more: "{items} und {count} weitere", + noItems: "(keine Einträge)", + blanks: Object.freeze({ exclude: "ohne leere Werte", include: "mit leeren Werten", only: "nur leere Werte" }), + withBlanks: "{text} ({blanks})", + in: phrase("{field} ist einer der Werte {items}", "{field} ist keiner der Werte {items}"), + blank: phrase("{field} ist leer", "{field} ist nicht leer"), + asShown: "{field} (wie angezeigt)", + text: Object.freeze({ + equals: phrase("{field} ist gleich {value}", "{field} ist nicht gleich {value}"), + contains: phrase("{field} enthält {value}", "{field} enthält nicht {value}"), + beginsWith: phrase("{field} beginnt mit {value}", "{field} beginnt nicht mit {value}"), + endsWith: phrase("{field} endet auf {value}", "{field} endet nicht auf {value}") + }), + match: "{text}, {case}, {whitespace}", + cases: Object.freeze({ insensitive: "Groß- und Kleinschreibung egal", sensitive: "Groß- und Kleinschreibung beachtet" }), + whitespace: Object.freeze({ collapse: "Leerraum zusammengefasst", exact: "Leerraum genau" }), + compare: phrase("{field} ist {op}", "{field} ist nicht {op}"), + ops: Object.freeze({ "=": "{value}", ">": "größer als {value}", ">=": "mindestens {value}", "<": "kleiner als {value}", "<=": "höchstens {value}", between: "zwischen {value} und {value2}" }), + precision: "{text} (nach {precision})", + precisions: Object.freeze({ year: "Jahr", quarter: "Quartal", month: "Monat", day: "Tag", hour: "Stunde" }), + relative: phrase("{field} liegt {range}", "{field} liegt nicht {range}"), + ranges: Object.freeze({ + last: deRanges("letzten", false), + next: deRanges("nächsten", false), + before: deRanges("letzten", true), + this: Object.freeze(Object.fromEntries(DATE_UNITS.map((u) => [u, DE_UNITS[u].this]))) + }), + how: "{text} ({how})", + rolling: "gleitend", + currentExcluded: "ohne den laufenden Zeitraum", + fromAnchor: "ab {anchor}", + anchors: Object.freeze({ latest: "dem letzten Datensatz", first: "dem ersten Datensatz" }), + top: "die obersten {count} von {field} nach {by}", + bottom: "die untersten {count} von {field} nach {by}", + tiesKept: "{text}, gleiche Werte behalten", + value: phrase("{field}, bei denen {by} {op} ist", "{field}, bei denen {by} nicht {op} ist"), + units: GROUPING_NAMES.de.units, + derived: "{name}: {field} nach {by}", + bins: "{name}: {field} nach {by} je {size}", + sortLabel: "{field} nach Beschriftung, {order}", + sortValue: "{field} nach {by}, {order}", + sortColumn: "{field} nach {by} in der Spalte {column}, {order}", + sortCustom: "{field} in eigener Reihenfolge, {order}", + orders: Object.freeze({ asc: "aufsteigend", desc: "absteigend" }), + rows: "nach {fields}", + cols: "über {fields}", + where: "(Filter: {filters})", + and: "; ", + chart: "als {type}", + both: "als Tabelle und {type}", + chartTypes: Object.freeze({ auto: "Diagramm", bar: "Balkendiagramm", line: "Liniendiagramm", area: "Flächendiagramm", pie: "Kreisdiagramm", donut: "Ringdiagramm", heatmap: "Heatmap", combo: "Balken- und Liniendiagramm", treemap: "Treemap" }), + invalid: Object.freeze({ one: "(ungültig: {count} Fehler, die Teile, die er nennt, fehlen)", other: "(ungültig: {count} Fehler, die Teile, die sie nennen, fehlen)" }) + }) +}); + +/** + * The DESCRIBE_LABELS of a locale's language ("de-DE": German), English for any other. + * @param {string} [locale] + * @returns {Readonly} + */ +export function describeLabels(locale) { + return String(locale ?? "").split("-")[0].toLowerCase() === "de" ? DESCRIBE_LABELS.de : DESCRIBE_LABELS.en; +} diff --git a/packages/pivotkit-core/src/describe.js b/packages/pivotkit-core/src/describe.js index d81167d26..7f557f36d 100644 --- a/packages/pivotkit-core/src/describe.js +++ b/packages/pivotkit-core/src/describe.js @@ -1,14 +1,17 @@ /* * Plain, structured summaries of a data set and of a view, for a person reading a log, an approver * and an LLM that writes or explains views: what fields there are and what a view does, as JSON with - * one short English `text` per part. Nothing here is formatted for a locale or rendered; values from + * one short `text` per part. The texts are English; describeView also writes German + * (DESCRIBE_LABELS in describe-labels.js). Nothing here is formatted for a locale or rendered; values from * the data are data (an LLM's prompt should mark them as such), capped in number and length. */ import { aggregatorsFor } from "./aggregators.js"; import { FILTERS } from "./filters.js"; +import { DESCRIBE_LABELS } from "./describe-labels.js"; import { isEncoded } from "./encode.js"; import { PivotkitError } from "./errors.js"; +import { fill, pluralForm } from "./labels.js"; import { isPlainObject, optionsOf } from "./util.js"; import { normalize, validate, viewFields } from "./view.js"; @@ -104,77 +107,103 @@ export function describeSource(data, options) { return { rows, fields: summaries, text: `${rows === null ? "" : `${count(rows, "row")}, `}${count(summaries.length, "field")}: ${summaries.map((f) => `${nameText(f.name)} (${f.type})`).join(", ")}` }; } -/** A value reference in words: "sum of Sales", "count of rows". */ -const refText = (ref) => (ref ? (ref.field ? `${ref.agg} of ${ref.field}` : `${ref.agg} of rows`) : "the first value"); +/** A word of a table by a name from a view (own entries only), else the name itself. */ +const wordOf = (table, name) => (table && Object.hasOwn(table, name) ? table[name] : name); + +/** A value reference in words: "sum of Sales", "count of rows"; German "Summe von Sales". */ +const refText = (ref, words) => { + if (!ref) { + return words.firstValue; + } + const agg = wordOf(words.aggregators, ref.agg); + return ref.field ? fill(words.valueName, { agg, field: ref.field }) : fill(words.valueOfRows, { agg }); +}; /** A list of items in words, capped. */ -const itemsText = (items) => { +const itemsText = (items, words) => { const shown = items.slice(0, 10).map((v) => (typeof v === "string" ? JSON.stringify(valueText(v, "string")) : String(v))); - return items.length > 10 ? `${shown.join(", ")} and ${items.length - 10} more` : shown.join(", "); + return items.length > 10 ? fill(words.more, { items: shown.join(", "), count: items.length - 10 }) : shown.join(", "); }; -const BLANKS_TEXT = Object.freeze({ exclude: "blanks dropped", include: "blanks kept", only: "only blanks" }); -/** The words of a comparison after "is" or "is not": "Year is 2025", "Year is not greater than 5". */ -const COMPARE_TEXT = Object.freeze({ "=": "", ">": "greater than ", ">=": "at least ", "<": "less than ", "<=": "at most ", between: "between " }); - -/** - * One filter of a normalized view in words: "Region is one of \"North\", \"South\" (blanks dropped)". - * @param {import("./view.js").FilterSpec} f - */ -export function filterText(f) { - const not = f.not ? "not " : ""; - const blanks = f.blanks ? ` (${BLANKS_TEXT[f.blanks]})` : ""; - const between = (a, b) => `${JSON.stringify(a)} and ${JSON.stringify(b)}`; +/** A filter's phrase and the values it is filled with: the phrase is built from words first, then filled once, so a name or value that holds "{field}" stays as it is. */ +function filterPhrase(f, words) { + const yesNot = (p) => (f.not ? p.not : p.yes); + const compared = { value: JSON.stringify(f.value), value2: JSON.stringify(f.value2) }; switch (f.type) { case "in": - return `${f.field} is ${not}one of ${itemsText(f.items ?? []) || "(no items)"}${blanks}`; + return { phrase: yesNot(words.in), values: { items: itemsText(f.items ?? [], words) || words.noItems } }; case "blank": - return `${f.field} is ${not}blank`; - case "text": - return `${f.field}${f.on === "label" ? " (as shown)" : ""} ${not ? "does not " : ""}${f.op === "equals" ? (not ? "equal" : "equals") : f.op === "contains" ? (not ? "contain" : "contains") : f.op === "beginsWith" ? (not ? "begin with" : "begins with") : not ? "end with" : "ends with"} ${JSON.stringify(f.value)}${f.match ? `, case ${f.match.case}, whitespace ${f.match.whitespace}` : ""}${blanks}`; - case "compare": - return `${f.field} ${not ? "is not" : "is"} ${COMPARE_TEXT[f.op]}${f.op === "between" ? between(f.value, f.value2) : JSON.stringify(f.value)}${f.precision && f.precision !== "day" ? ` (by ${f.precision})` : ""}${blanks}`; + return { phrase: yesNot(words.blank), values: {}, blanks: false }; + case "text": { + const own = fill(yesNot(words.text[f.op]), f.on === "label" ? { field: words.asShown } : {}); + const phrase = f.match ? fill(words.match, { text: own, case: wordOf(words.cases, f.match.case), whitespace: wordOf(words.whitespace, f.match.whitespace) }) : own; + return { phrase, values: { value: JSON.stringify(f.value) } }; + } + case "compare": { + const phrase = fill(yesNot(words.compare), { op: words.ops[f.op] }); + return { phrase: f.precision && f.precision !== "day" ? fill(words.precision, { text: phrase, precision: wordOf(words.precisions, f.precision) }) : phrase, values: compared }; + } case "relative": { - const range = f.direction === "this" ? `this ${f.unit}` : `${f.direction} ${f.count} ${f.unit}${f.count === 1 ? "" : "s"}`; - const how = [f.calendar === false ? "rolling" : null, f.includeCurrent === false ? "current excluded" : null, f.anchor && f.anchor !== "today" ? `from ${f.anchor}` : null].filter(Boolean); - return `${f.field} ${not ? "is not" : "is"} in the ${range}${how.length ? ` (${how.join(", ")})` : ""}${blanks}`; + const range = f.direction === "this" ? wordOf(words.ranges.this, f.unit) : pluralForm(words.ranges[f.direction]?.[f.unit], f.count, words.lang); + const phrase = fill(yesNot(words.relative), { range }); + const how = [f.calendar === false ? words.rolling : null, f.includeCurrent === false ? words.currentExcluded : null, f.anchor && f.anchor !== "today" ? fill(words.fromAnchor, { anchor: Object.hasOwn(words.anchors, f.anchor) ? words.anchors[f.anchor] : "{anchor}" }) : null].filter(Boolean); + return { phrase: how.length ? fill(words.how, { text: phrase, how: how.join(", ") }) : phrase, values: { count: f.count, anchor: f.anchor } }; + } + case "top": { + const phrase = f.bottom ? words.bottom : words.top; + return { phrase: f.ties === "all" ? fill(words.tiesKept, { text: phrase }) : phrase, values: { count: f.count, by: refText(f.by, words) }, blanks: false }; } - case "top": - return `${f.bottom ? "bottom" : "top"} ${f.count} ${f.field} by ${refText(f.by)}${f.ties === "all" ? ", ties kept" : ""}`; case "value": - return `${f.field} where ${refText(f.by)} ${not ? "is not" : "is"} ${COMPARE_TEXT[f.op]}${f.op === "between" ? between(f.value, f.value2) : JSON.stringify(f.value)}`; + return { phrase: fill(yesNot(words.value), { op: words.ops[f.op] }), values: { by: refText(f.by, words), ...compared }, blanks: false }; default: - return `${f.field}: ${f.type}`; + return { phrase: "{field}: {type}", values: { type: f.type }, blanks: false }; } } +/** + * One filter of a normalized view in words: "Region is one of \"North\", \"South\" (blanks dropped)". + * @param {import("./view.js").FilterSpec} f + * @param {import("./describe-labels.js").DescribeLabels} [words] default English + */ +export function filterText(f, words = DESCRIBE_LABELS.en) { + const { phrase, values, blanks } = filterPhrase(f, words); + const withBlanks = blanks !== false && f.blanks ? fill(words.withBlanks, { text: phrase, blanks: words.blanks[f.blanks] }) : phrase; + return fill(withBlanks, { ...values, field: f.field }); +} + /** * A view in plain parts: what it shows (rows, columns, values with their names), what it filters (each * filter structured, with its words), its groupings, sort and display, whether it is valid against the - * data and what is wrong (validate()'s errors and warnings), and one short English `text` of it all. + * data and what is wrong (validate()'s errors and warnings), and one short `text` of it all. * The view is normalized first; the parts are the normalized view's, so a part with an error is left * out of them, and `text` of an invalid view starts with "(invalid: n errors, ...)". + * The `text`s are English unless `options.labels` gives other words: DESCRIBE_LABELS.de or + * describeLabels(locale) for German. A partial `labels` takes English for each key it leaves out. + * validate()'s errors and warnings stay English. * @param {unknown} input a view (any input normalize() takes) * @param {unknown} schema encoded data, { fields } or the fields array - * @param {{ limits?: Partial }} [options] + * @param {{ limits?: Partial, labels?: Partial }} [options] */ export function describeView(input, schema, options) { options = optionsOf(options, "describeView"); + const words = /** @type {import("./describe-labels.js").DescribeLabels} */ ({ ...DESCRIBE_LABELS.en, ...(isPlainObject(options.labels) ? options.labels : {}) }); const { valid, errors, warnings } = validate(input, schema, options); const view = normalize(input, schema, options).view; - const values = view.values.map((v) => ({ field: v.field, agg: v.agg, label: v.label, showAs: v.showAs?.type ?? null, text: v.label ?? refText(v) })); - const filters = view.filters.map((f) => ({ ...f, text: filterText(f) })); - const derived = view.derived.map((d) => ({ ...d, text: `${d.name}: ${d.field} by ${d.by}${d.by === "bin" ? ` of ${d.size}` : ""}` })); + const values = view.values.map((v) => ({ field: v.field, agg: v.agg, label: v.label, showAs: v.showAs?.type ?? null, text: v.label ?? refText(v, words) })); + const filters = view.filters.map((f) => ({ ...f, text: filterText(f, words) })); + const derived = view.derived.map((d) => ({ ...d, text: fill(d.by === "bin" ? words.bins : words.derived, { name: d.name, field: d.field, by: wordOf(words.units, d.by), size: d.size }) })); // a sort's column holds one key per column field: a date's key is milliseconds, written as its day const types = new Map(viewFields(view, schema).map((f) => [f.name, f.type])); const keyText = (key, i) => (types.get(view.cols[i]) === "date" ? (valueText(key, "date") ?? String(key)) : String(key)); - const sort = view.sort.map((s) => ({ ...s, text: `${s.field} ${s.by === "value" ? `by ${refText(s.value)}${s.column ? ` in the column ${s.column.map(keyText).join(" › ")}` : ""}` : s.by === "custom" ? "in a custom order" : "by label"}, ${s.order === "desc" ? "descending" : "ascending"}` })); + const sortPhrase = (s) => (s.by === "value" ? (s.column ? words.sortColumn : words.sortValue) : s.by === "custom" ? words.sortCustom : words.sortLabel); + const sort = view.sort.map((s) => ({ ...s, text: fill(sortPhrase(s), { field: s.field, by: s.by === "value" ? refText(s.value, words) : "", column: s.column ? s.column.map(keyText).join(" › ") : "", order: s.order === "desc" ? words.orders.desc : words.orders.asc }) })); + const chart = wordOf(words.chartTypes, view.chart.type); const parts = [ - values.length ? values.map((v) => v.text).join(", ") : "count of rows", - view.rows.length ? `by ${view.rows.join(" > ")}` : null, - view.cols.length ? `across ${view.cols.join(" > ")}` : null, - filters.length ? `where ${filters.map((f) => f.text).join("; and ")}` : null, - view.display === "table" ? null : `as a ${view.display === "both" ? "table and a " : ""}${view.chart.type === "auto" ? "chart" : `${view.chart.type} chart`}` + values.length ? values.map((v) => v.text).join(", ") : words.countRows, + view.rows.length ? fill(words.rows, { fields: view.rows.join(" > ") }) : null, + view.cols.length ? fill(words.cols, { fields: view.cols.join(" > ") }) : null, + filters.length ? fill(words.where, { filters: filters.map((f) => f.text).join(words.and) }) : null, + view.display === "table" ? null : fill(view.display === "both" ? words.both : words.chart, { type: chart }) ]; return { valid, @@ -187,6 +216,6 @@ export function describeView(input, schema, options) { derived, sort, display: { mode: view.display, chart: view.display === "table" ? null : view.chart.type }, - text: `${valid ? "" : `(invalid: ${errors.length} error${errors.length === 1 ? "" : "s"}, the parts they name are left out) `}${parts.filter(Boolean).join(" ")}` + text: `${valid ? "" : `${fill(pluralForm(words.invalid, errors.length, words.lang), { count: errors.length })} `}${parts.filter(Boolean).join(" ")}` }; } diff --git a/packages/pivotkit-core/src/index.js b/packages/pivotkit-core/src/index.js index 1e95789b0..92fb512ef 100644 --- a/packages/pivotkit-core/src/index.js +++ b/packages/pivotkit-core/src/index.js @@ -48,6 +48,7 @@ * @typedef {import("./format.js").Formatter} Formatter * @typedef {import("./limits.js").Limits} Limits * @typedef {import("./labels.js").Labels} Labels + * @typedef {import("./describe-labels.js").DescribeLabels} DescribeLabels * @typedef {import("./schema.js").SchemaFieldDefaults} SchemaFieldDefaults * @typedef {import("./errors.js").PivotkitErrorCode} PivotkitErrorCode * @typedef {import("./view-file.js").ViewFileMeta} ViewFileMeta @@ -77,6 +78,7 @@ export { formatter, isFormat } from "./format.js"; export { aggregatorsFor, AGGREGATOR_ALIASES } from "./aggregators.js"; export { CATALOG } from "./catalog.js"; export { describeSource, describeView, DESCRIBE_LIMITS } from "./describe.js"; +export { DESCRIBE_LABELS, describeLabels } from "./describe-labels.js"; export { DEFAULT_LABELS, GROUPING_NAMES, PLURAL_CATEGORIES, REPORT_LABELS, ROW_COUNT_TEXTS, fieldLabel, groupingName, pluralForm, reportLabels, withFieldLabels } from "./labels.js"; export { fieldDefaultsFromSchema } from "./schema.js"; export { COLOR_SCALES, DEFAULT_THEME } from "./defaults.js"; diff --git a/packages/pivotkit-core/test/api.test.js b/packages/pivotkit-core/test/api.test.js index 3b6df7eca..990e7fd3e 100644 --- a/packages/pivotkit-core/test/api.test.js +++ b/packages/pivotkit-core/test/api.test.js @@ -16,8 +16,8 @@ const src = fileURLToPath(new URL("../src/", import.meta.url)); test("the package exports its documented entry points and nothing else", () => { assert.deepEqual(Object.keys(core).sort(), [ - "AGGREGATOR_ALIASES", "CATALOG", "CHART_COLORS", "COLOR_SCALES", "DEFAULT_LABELS", "DEFAULT_THEME", "DESCRIBE_LIMITS", "GROUPING_NAMES", "HINT_LIMITS", "ISSUE_CAP", "LAYOUT_LIMITS", "LIMITS", "MATCH_DEFAULTS", "MAX_DATE_MS", "OUTSIDE_LIMITS", "PLURAL_CATEGORIES", "PivotkitError", "REPORT_LABELS", "ROW_COUNT_TEXTS", "SUGGEST_LIMITS", "VIEW_FILE_FORMAT", "VIEW_FILE_LIMITS", "VIEW_FILE_SCHEMA", "VIEW_FILE_VERSION", "VIEW_ISSUES", "VIEW_ISSUE_CODES", "VIEW_VERSION", "aggregatorsFor", "autoChartType", - "cellRows", "chartPlan", "chartThemeFrom", "closest", "computePivot", "createHistory", "dateUnitFor", "describeSource", "describeView", "emptyView", "encode", "fieldDefaultsFromSchema", "fieldItems", "fieldLabel", "findNode", "foldText", "formatter", "fromViewFile", "groupingName", "isDateMs", "isFormat", "isIdentifierName", "linkFragment", "linkParam", + "AGGREGATOR_ALIASES", "CATALOG", "CHART_COLORS", "COLOR_SCALES", "DEFAULT_LABELS", "DEFAULT_THEME", "DESCRIBE_LABELS", "DESCRIBE_LIMITS", "GROUPING_NAMES", "HINT_LIMITS", "ISSUE_CAP", "LAYOUT_LIMITS", "LIMITS", "MATCH_DEFAULTS", "MAX_DATE_MS", "OUTSIDE_LIMITS", "PLURAL_CATEGORIES", "PivotkitError", "REPORT_LABELS", "ROW_COUNT_TEXTS", "SUGGEST_LIMITS", "VIEW_FILE_FORMAT", "VIEW_FILE_LIMITS", "VIEW_FILE_SCHEMA", "VIEW_FILE_VERSION", "VIEW_ISSUES", "VIEW_ISSUE_CODES", "VIEW_VERSION", "aggregatorsFor", "autoChartType", + "cellRows", "chartPlan", "chartThemeFrom", "closest", "computePivot", "createHistory", "dateUnitFor", "describeLabels", "describeSource", "describeView", "emptyView", "encode", "fieldDefaultsFromSchema", "fieldItems", "fieldLabel", "findNode", "foldText", "formatter", "fromViewFile", "groupingName", "isDateMs", "isFormat", "isIdentifierName", "linkFragment", "linkParam", "migrate", "monthName", "normalize", "numberRepeats", "outsideLimits", "pluralForm", "referenceLineRules", "relativeDateRange", "renameFields", "reportLabels", "stacksToPercent", "suggestDateUnit", "suggestLayout", "swapAxes", "toEChartsOption", "toGrid", "toSeries", "toViewFile", "validate", "valueAddsUp", "viewFields", "viewFileFields", "viewFileName", "viewFileText", "viewFromLayout", "withFieldLabels", "withLinkFragment" ]); assert.deepEqual(Object.keys(exporters).sort(), ["dataToCsv", "dataToCsvBytes", "dataToCsvParts", "dataToJson", "isDataAsOf", "rowsToCsv", "rowsToCsvBytes", "rowsToXlsx", "scaleColor", "toCsv", "toCsvBytes", "toJson", "toTsv", "toXlsx"]); diff --git a/packages/pivotkit-core/test/describe.test.js b/packages/pivotkit-core/test/describe.test.js index 5465358bf..d0eabc040 100644 --- a/packages/pivotkit-core/test/describe.test.js +++ b/packages/pivotkit-core/test/describe.test.js @@ -1,6 +1,6 @@ import { test } from "node:test"; import assert from "node:assert/strict"; -import { DESCRIBE_LIMITS, PivotkitError, describeSource, describeView, encode } from "../src/index.js"; +import { DESCRIBE_LABELS, DESCRIBE_LIMITS, PivotkitError, describeLabels, describeSource, describeView, encode } from "../src/index.js"; import { SALES } from "./fixtures.js"; const data = encode(SALES); @@ -112,3 +112,49 @@ test("describeView: a comparison and a text rule in words for each operator, wit assert.equal(text({ field: "Rep", type: "text", op: "endsWith", value: "n", not: true }), 'Rep does not end with "n", case insensitive, whitespace collapse (blanks dropped)'); assert.equal(text({ field: "Rep", type: "text", op: "equals", value: "Ann", not: true }), 'Rep does not equal "Ann", case insensitive, whitespace collapse (blanks dropped)'); }); + +test("describeView in German: every filter type, the parts and the whole sentence", () => { + const de = { labels: DESCRIBE_LABELS.de }; + const text = (filter) => describeView({ version: 2, filters: [{ blanks: "exclude", ...filter }] }, data, de).filters[0].text; + // "=" is the value alone, as in English: "Units ist 5", never "ist ist" + assert.equal(text({ field: "Units", type: "compare", op: "=", value: 5 }), "Units ist 5 (ohne leere Werte)"); + assert.equal(text({ field: "Units", type: "compare", op: "=", value: 5, not: true }), "Units ist nicht 5 (ohne leere Werte)"); + assert.equal(text({ field: "Units", type: "compare", op: "between", value: 1, value2: 9 }), "Units ist zwischen 1 und 9 (ohne leere Werte)"); + assert.equal(text({ field: "Date", type: "compare", op: ">", value: "2026-01-01", precision: "month" }), 'Date ist größer als "2026-01-01" (nach Monat) (ohne leere Werte)'); + assert.equal(text({ field: "Region", type: "in", items: ["North", "South"], blanks: "include" }), 'Region ist einer der Werte "North", "South" (mit leeren Werten)'); + assert.equal(text({ field: "Region", type: "in", items: [], not: true }), "Region ist keiner der Werte (keine Einträge) (ohne leere Werte)"); + assert.equal(text({ field: "Region", type: "blank", not: true }), "Region ist nicht leer"); + assert.equal(text({ field: "Rep", type: "text", op: "contains", value: "a", on: "label" }), 'Rep (wie angezeigt) enthält "a", Groß- und Kleinschreibung egal, Leerraum zusammengefasst (ohne leere Werte)'); + assert.equal(text({ field: "Rep", type: "text", op: "endsWith", value: "n", not: true, match: { case: "sensitive", whitespace: "exact" } }), 'Rep endet nicht auf "n", Groß- und Kleinschreibung beachtet, Leerraum genau (ohne leere Werte)'); + assert.equal(text({ field: "Date", type: "relative", direction: "this", unit: "year" }), "Date liegt in diesem Jahr (ohne leere Werte)"); + assert.equal(text({ field: "Date", type: "relative", direction: "last", count: 1, unit: "month" }), "Date liegt im letzten Monat (ohne leere Werte)"); + assert.equal(text({ field: "Date", type: "relative", direction: "next", count: 3, unit: "week", anchor: "2026-01-05" }), "Date liegt in den nächsten 3 Wochen (ab 2026-01-05) (ohne leere Werte)"); + assert.equal(text({ field: "Date", type: "relative", direction: "before", count: 2, unit: "day", calendar: false, includeCurrent: false, anchor: "latest" }), "Date liegt vor den letzten 2 Tagen (gleitend, ohne den laufenden Zeitraum, ab dem letzten Datensatz) (ohne leere Werte)"); + assert.equal(text({ field: "Region", type: "top", count: 2, by: { field: "Units", agg: "sum" }, ties: "all" }), "die obersten 2 von Region nach Summe von Units, gleiche Werte behalten"); + assert.equal(text({ field: "Region", type: "value", op: "=", value: 5, by: { field: "Units", agg: "sum" } }), "Region, bei denen Summe von Units 5 ist"); + const d = describeView({ + version: 2, rows: ["Region", "Month"], cols: ["Product"], derived: [{ name: "Month", field: "Date", by: "yearMonth" }], + values: [{ field: "Units", agg: "sum" }, { agg: "count" }], display: "both", chart: { type: "bar" }, + filters: [{ field: "Units", type: "compare", op: ">", value: 1 }, { field: "Region", type: "blank", not: true }], + sort: [{ field: "Region", by: "value", value: { field: "Units", agg: "sum" }, order: "desc" }, { field: "Product", by: "label", order: "asc" }] + }, data, de); + assert.equal(d.text, "Summe von Units, Anzahl der Zeilen nach Region > Month über Product (Filter: Units ist größer als 1 (ohne leere Werte); Region ist nicht leer) als Tabelle und Balkendiagramm"); + assert.deepEqual(d.derived.map((x) => x.text), ["Month: Date nach Monat"]); + assert.deepEqual(d.sort.map((x) => x.text), ["Region nach Summe von Units, absteigend", "Product nach Beschriftung, aufsteigend"]); + assert.equal(describeView({ version: 2, rows: ["Nope"] }, data, de).text, "(ungültig: 1 Fehler, die Teile, die er nennt, fehlen) Anzahl der Zeilen"); + assert.equal(describeLabels("de-AT"), DESCRIBE_LABELS.de); + assert.equal(describeLabels("fr-FR"), DESCRIBE_LABELS.en); +}); + +test("describeView fills its words once: a name or a value that looks like a placeholder stays as it is", () => { + const odd = encode([{ "{value}": "{field}", n: 1 }]); + for (const labels of [undefined, DESCRIBE_LABELS.de]) { + const d = describeView({ version: 2, filters: [{ field: "{value}", type: "text", op: "equals", value: "{field}" }] }, odd, { labels }); + assert.match(d.filters[0].text, /^\{value\} (equals|ist gleich) "\{field\}"/); + } +}); + +test("describeView: labels that leave a key out take English for it", () => { + const d = describeView({ version: 2, rows: ["Region"], filters: [{ field: "Units", type: "compare", op: ">", value: 1 }] }, data, { labels: { rows: "per {fields}" } }); + assert.equal(d.text, "count of rows per Region where Units is greater than 1 (blanks dropped)"); +}); diff --git a/packages/pivotkit-core/test/types/consumer.ts b/packages/pivotkit-core/test/types/consumer.ts index 392ea81aa..8dce63df5 100644 --- a/packages/pivotkit-core/test/types/consumer.ts +++ b/packages/pivotkit-core/test/types/consumer.ts @@ -1,7 +1,7 @@ // Compiled by `npm run test:types` against the generated declarations, through the package's own // exports map: the published types must describe the public API as a TypeScript user sees it. import { - computePivot, dateUnitFor, describeSource, encode, fieldDefaultsFromSchema, fieldLabel, foldText, GROUPING_NAMES, groupingName, isDateMs, isIdentifierName, LIMITS, + computePivot, dateUnitFor, DESCRIBE_LABELS, describeLabels, describeSource, describeView, encode, fieldDefaultsFromSchema, fieldLabel, foldText, GROUPING_NAMES, groupingName, isDateMs, isIdentifierName, LIMITS, MAX_DATE_MS, normalize, outsideLimits, PivotkitError, relativeDateRange, renameFields, suggestLayout, toEChartsOption, toGrid, validate, viewFromLayout, type ColumnarData, type EncodeIssue, type Grid, type LayoutView, type PivotResult, type SchemaFieldDefaults, type View } from "pivotkit-core"; @@ -91,6 +91,8 @@ const noteCodes: string[] = built.notes.map((n) => n.code); const renamed: string[] = renameFields(built.view, { Region: "Area" }).unused; const unit: string | null = dateUnitFor(0, 86_400_000 * 90); const grouped: string = groupingName("Date", "yearMonth", { locale: "de-DE" }) + GROUPING_NAMES.en.name; +// a view in German words, from the table or a locale; a partial table keeps English for the rest +const inGerman: string = describeView({ rows: ["Region"] }, described, { labels: describeLabels("de-DE") }).text + describeView({ rows: ["Region"] }, described, { labels: { rows: DESCRIBE_LABELS.de.rows } }).text; const identifier: boolean = isIdentifierName("Order No"); const sourceId: Promise = sourceIdOf("sales.csv", ["Region", "Units"]); void normalize(built.view, data); @@ -108,5 +110,6 @@ void noteCodes; void renamed; void unit; void grouped; +void inGerman; void identifier; void sourceId; diff --git a/scripts/growth-baseline.json b/scripts/growth-baseline.json index f416c24d1..0f6dbb7d6 100644 --- a/scripts/growth-baseline.json +++ b/scripts/growth-baseline.json @@ -16,7 +16,7 @@ "docs/security.md": [896], "docs/use/charts.md": [481] }, - "totalLines": 24133 + "totalLines": 24045 }, "functions": { "complexity": { @@ -26,7 +26,6 @@ "packages/pivotkit-core/src/chart-style.js Arrow function": [50], "packages/pivotkit-core/src/chart-style.js Function 'decorateOption'": [136], "packages/pivotkit-core/src/chart.js Function 'toEChartsOption'": [88], - "packages/pivotkit-core/src/describe.js Function 'filterText'": [38], "packages/pivotkit-core/src/filters.js Function 'relativeDateRange'": [30], "packages/pivotkit-core/src/import-csv.js Function 'splitRows'": [29], "packages/pivotkit-core/src/import-json.js Async function 'read'": [29], From cb33a75d08a8577e437603b903572da604dab8d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Eizedev?= <6794362+eizedev@users.noreply.github.com> Date: Wed, 25 Nov 2026 16:44:16 +0100 Subject: [PATCH 02/20] fix(report): a German HTML report writes its filters and summary in German render passes the words of the report's language to describeView, so {{filters}}, {{summary}} and the page description follow the locale as the report's other words do. Refs #798 Co-Authored-By: Claude Opus 5.5 --- docs/reference/print-template.md | 4 ++-- packages/pivotkit-report/CHANGELOG.md | 5 +++++ packages/pivotkit-report/src/render.js | 5 +++-- packages/pivotkit-report/test/golden/report.html | 4 ++-- packages/pivotkit-report/test/render.test.js | 4 ++++ 5 files changed, 16 insertions(+), 6 deletions(-) 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 `