@eifi1/ui-kit 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -6
- package/dist/chart.d.ts +4 -1
- package/dist/components/amount-input.d.ts +4 -1
- package/dist/components/button-group.d.ts +4 -1
- package/dist/components/calculator.d.ts +4 -1
- package/dist/components/copy-button.d.ts +4 -1
- package/dist/components/facing-pair.d.ts +4 -1
- package/dist/components/file-button.d.ts +4 -1
- package/dist/components/file-dropzone.d.ts +4 -1
- package/dist/components/floating-panel.d.ts +4 -1
- package/dist/components/floating-panel.js +15 -1
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/form-actions.d.ts +4 -1
- package/dist/components/legal.d.ts +84 -0
- package/dist/components/legal.js +55 -0
- package/dist/components/legal.js.map +1 -0
- package/dist/components/money-field.d.ts +4 -1
- package/dist/components/number-field.d.ts +4 -1
- package/dist/components/number-input.d.ts +4 -1
- package/dist/components/numpad-sheet.d.ts +4 -1
- package/dist/components/series-chart.d.ts +4 -1
- package/dist/components/server-wake.d.ts +4 -2
- package/dist/components/server-wake.js +23 -2
- package/dist/components/server-wake.js.map +1 -1
- package/dist/components/settings-fields.d.ts +4 -1
- package/dist/components/share-card.d.ts +4 -1
- package/dist/components/text-link.d.ts +4 -1
- package/dist/components/time-input.d.ts +4 -1
- package/dist/components/translation-review-editor.d.ts +56 -0
- package/dist/components/translation-review-editor.js +159 -0
- package/dist/components/translation-review-editor.js.map +1 -0
- package/dist/components/translation-review-labels.d.ts +92 -0
- package/dist/components/translation-review-labels.js +67 -0
- package/dist/components/translation-review-labels.js.map +1 -0
- package/dist/components/translation-review-parts.d.ts +97 -0
- package/dist/components/translation-review-parts.js +163 -0
- package/dist/components/translation-review-parts.js.map +1 -0
- package/dist/components/translation-review.d.ts +94 -0
- package/dist/components/translation-review.js +344 -0
- package/dist/components/translation-review.js.map +1 -0
- package/dist/components/ui.d.ts +4 -1
- package/dist/hooks/use-file-drop.d.ts +4 -1
- package/dist/i18n/defaults.d.ts +4 -1
- package/dist/i18n/defaults.js +5 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.d.ts +4 -1
- package/dist/i18n/german.js +51 -0
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +4 -1
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +243 -0
- package/dist/i18n/languages.js +70 -0
- package/dist/i18n/languages.js.map +1 -0
- package/dist/i18n/locales/de-CH.d.ts +4 -1
- package/dist/i18n/locales/en.d.ts +4 -1
- package/dist/i18n/locales/en.js +8 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +4 -1
- package/dist/i18n/locales/es.js +83 -33
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +4 -1
- package/dist/i18n/locales/fr.js +50 -0
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +4 -1
- package/dist/i18n/locales/hu.js +51 -0
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +4 -1
- package/dist/i18n/locales/it.js +90 -40
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +4 -1
- package/dist/i18n/locales/zh.js +51 -0
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +102 -0
- package/dist/i18n/review.js +158 -0
- package/dist/i18n/review.js.map +1 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -1
- package/dist/{kit-labels-CPbsjlXr.d.ts → kit-labels-D1J2_jyD.d.ts} +7 -0
- package/dist/lib/floating-stack.d.ts +31 -0
- package/dist/lib/floating-stack.js +42 -0
- package/dist/lib/floating-stack.js.map +1 -0
- package/dist/lib/server-wake.d.ts +24 -8
- package/dist/lib/server-wake.js +6 -5
- package/dist/lib/server-wake.js.map +1 -1
- package/dist/lib/translation-review.d.ts +232 -0
- package/dist/lib/translation-review.js +194 -0
- package/dist/lib/translation-review.js.map +1 -0
- package/dist/rhf/fields.d.ts +4 -1
- package/dist/rhf/form.d.ts +4 -1
- package/dist/rhf.d.ts +4 -1
- package/dist/shell/app-shell.d.ts +4 -1
- package/dist/shell/top-bar-brand.d.ts +4 -1
- package/dist/shell.d.ts +4 -1
- package/dist/wizard/stepper-nav.d.ts +4 -1
- package/dist/wizard.d.ts +4 -1
- package/package.json +1 -1
- package/src/components/floating-panel.tsx +19 -1
- package/src/components/legal.tsx +159 -0
- package/src/components/server-wake.tsx +37 -5
- package/src/components/translation-review-editor.tsx +261 -0
- package/src/components/translation-review-labels.ts +152 -0
- package/src/components/translation-review-parts.tsx +269 -0
- package/src/components/translation-review.tsx +502 -0
- package/src/i18n/defaults.ts +4 -0
- package/src/i18n/german.ts +52 -0
- package/src/i18n/kit-labels.tsx +7 -0
- package/src/i18n/languages.ts +285 -0
- package/src/i18n/locales/en.ts +8 -0
- package/src/i18n/locales/es.ts +84 -33
- package/src/i18n/locales/fr.ts +51 -0
- package/src/i18n/locales/hu.ts +52 -0
- package/src/i18n/locales/it.ts +91 -40
- package/src/i18n/locales/zh.ts +52 -0
- package/src/i18n/review.ts +193 -0
- package/src/index.ts +63 -0
- package/src/lib/floating-stack.ts +66 -0
- package/src/lib/server-wake.ts +34 -13
- package/src/lib/translation-review.ts +465 -0
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
import { useMemo, useState } from "react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import { Check, ListChecks, RotateCcw } from "lucide-react";
|
|
4
|
+
|
|
5
|
+
import { useKitLabels, useKitLocale } from "../i18n/kit-labels";
|
|
6
|
+
import { cn } from "../lib/cn";
|
|
7
|
+
import {
|
|
8
|
+
DEFAULT_TRANSLATION_REVIEW_FILTER,
|
|
9
|
+
REVIEW_STATUSES,
|
|
10
|
+
filterTranslationRows,
|
|
11
|
+
keyInAreas,
|
|
12
|
+
reviewWrite,
|
|
13
|
+
summariseRows,
|
|
14
|
+
} from "../lib/translation-review";
|
|
15
|
+
import type {
|
|
16
|
+
ReviewStatus,
|
|
17
|
+
TranslationReviewFilter,
|
|
18
|
+
TranslationReviewKey,
|
|
19
|
+
TranslationReviewWrite,
|
|
20
|
+
TranslationRow,
|
|
21
|
+
} from "../lib/translation-review";
|
|
22
|
+
import { AlertBanner } from "./alert-banner";
|
|
23
|
+
import { BulkActionBar } from "./bulk-action-bar";
|
|
24
|
+
import { Checkbox } from "./checkbox";
|
|
25
|
+
import { Chip } from "./chip";
|
|
26
|
+
import { DataTable } from "./data-table";
|
|
27
|
+
import type { DataTableColumn } from "./data-table";
|
|
28
|
+
import { SearchField } from "./search-field";
|
|
29
|
+
import { ToggleGroup } from "./toggle-group";
|
|
30
|
+
import { TranslationReviewEditor } from "./translation-review-editor";
|
|
31
|
+
import { DEFAULT_TRANSLATION_REVIEW_LABELS, reviewStatusLabel } from "./translation-review-labels";
|
|
32
|
+
import type { TranslationReviewLabels } from "./translation-review-labels";
|
|
33
|
+
import { ReviewStatusChip, TranslationProgress } from "./translation-review-parts";
|
|
34
|
+
import { Button, IconButton, Select } from "./ui";
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
REVIEW_STATUS_TONES,
|
|
38
|
+
ReviewStatusChip,
|
|
39
|
+
TranslationExportButton,
|
|
40
|
+
TranslationLocaleTabs,
|
|
41
|
+
TranslationProgress,
|
|
42
|
+
} from "./translation-review-parts";
|
|
43
|
+
export type {
|
|
44
|
+
ReviewStatusChipProps,
|
|
45
|
+
TranslationExportButtonProps,
|
|
46
|
+
TranslationLocaleTab,
|
|
47
|
+
TranslationLocaleTabsProps,
|
|
48
|
+
TranslationProgressProps,
|
|
49
|
+
} from "./translation-review-parts";
|
|
50
|
+
export { TranslationReviewEditor } from "./translation-review-editor";
|
|
51
|
+
export type { TranslationReviewEditorProps } from "./translation-review-editor";
|
|
52
|
+
export { DEFAULT_TRANSLATION_REVIEW_LABELS } from "./translation-review-labels";
|
|
53
|
+
export type { TranslationReviewLabels } from "./translation-review-labels";
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* An app's translation review page, as kit parts (H1, docs/i18n-harmonization.md):
|
|
57
|
+
* keksdose's /translations, which kastlan was about to build a second time. The app keeps
|
|
58
|
+
* what is its own — where the strings come from, which locale is read against which, who
|
|
59
|
+
* may review what, every request — and hands the kit rows (`translationRows`) and two
|
|
60
|
+
* callbacks. Everything a reviewer touches is here.
|
|
61
|
+
*
|
|
62
|
+
* Presentational — no request, no route — and one LOCALE at a time. Its table is the
|
|
63
|
+
* kit's DataTable, so like every DataTable it renders under the app's Router. The page
|
|
64
|
+
* around it puts
|
|
65
|
+
* {@link TranslationLocaleTabs} above it and {@link TranslationExportButton} in its header,
|
|
66
|
+
* because both span every locale while this panel is the one open.
|
|
67
|
+
*
|
|
68
|
+
* Callbacks may return promises, and the panel waits for them: an editor stays open with
|
|
69
|
+
* its text and the error when a save is refused (a 403 for a key outside the reviewer's
|
|
70
|
+
* areas, a network failure), a bulk action keeps its selection. Chunking a long bulk
|
|
71
|
+
* write to the server's batch limit is the app's; the panel sends one call per action.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
type MaybePromise = void | Promise<unknown>;
|
|
75
|
+
|
|
76
|
+
export interface TranslationReviewPanelProps {
|
|
77
|
+
/** One locale's rows, from `translationRows`. */
|
|
78
|
+
rows: readonly TranslationRow[];
|
|
79
|
+
/** The reviewed language's own name — the text column's header ("Français"). */
|
|
80
|
+
localeLabel: string;
|
|
81
|
+
/** The reference language's own name — the reference column's header. */
|
|
82
|
+
referenceLabel: string;
|
|
83
|
+
/** Store verdicts: one for an editor or a row's approve button, many for a bulk
|
|
84
|
+
* approve. Left out (or `readOnly`): nothing can be changed. */
|
|
85
|
+
onSave?: (writes: TranslationReviewWrite[]) => MaybePromise;
|
|
86
|
+
/** Clear verdicts — back to unreviewed. Left out: no reset. */
|
|
87
|
+
onClear?: (keys: TranslationReviewKey[]) => MaybePromise;
|
|
88
|
+
/** A locale the viewer may read but not review: the rows and their verdicts, no
|
|
89
|
+
* actions, and a line saying so. */
|
|
90
|
+
readOnly?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* The areas the reviewer is limited to (keksdose's lawyer: `["legal"]`), as the server
|
|
93
|
+
* answers them; `null` is every area. Rows outside are not shown or counted — build the
|
|
94
|
+
* rows with the same `areas` and they never exist — and a notice names the areas.
|
|
95
|
+
*/
|
|
96
|
+
areas?: readonly string[] | null;
|
|
97
|
+
/** An area's name for the notice ("the legal pages (Imprint, …)"). Default: the key. */
|
|
98
|
+
areaLabels?: Readonly<Record<string, string>>;
|
|
99
|
+
/** Default `keyInArea`: the key is the area or sits under it (`legal.…`, `legal:…`). */
|
|
100
|
+
inArea?: (key: string, area: string) => boolean;
|
|
101
|
+
/** A source's name for the source filter, which appears once the rows come from more
|
|
102
|
+
* than one (kastlan: `{ screen: "Screen", documents: "PDFs and emails" }`). Default:
|
|
103
|
+
* the source itself. */
|
|
104
|
+
sourceLabels?: Readonly<Record<string, string>>;
|
|
105
|
+
/**
|
|
106
|
+
* Controlled filters — for an app that keeps them in the URL (keksdose's `?status=`,
|
|
107
|
+
* `?area=`, `?q=`). Whatever is left out is the panel's own. Pair with `onFilterChange`.
|
|
108
|
+
*/
|
|
109
|
+
filter?: Partial<TranslationReviewFilter>;
|
|
110
|
+
onFilterChange?: (filter: TranslationReviewFilter) => void;
|
|
111
|
+
/** The progress bar over the filters. Default true. */
|
|
112
|
+
progress?: boolean;
|
|
113
|
+
/** Rows per page. Default 50. */
|
|
114
|
+
pageSize?: number;
|
|
115
|
+
/** Persists the table's sort and page size (DataTable's `storageKey`). */
|
|
116
|
+
storageKey?: string;
|
|
117
|
+
/** How a verdict's date reads in the editor. */
|
|
118
|
+
formatDate?: (iso: string) => string;
|
|
119
|
+
/** Turns a callback's rejection into words. Default {@link TranslationReviewLabels.failed}. */
|
|
120
|
+
formatError?: (error: unknown) => ReactNode;
|
|
121
|
+
className?: string;
|
|
122
|
+
labels?: Partial<TranslationReviewLabels>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** The row's text — or, for a missing string, the line that says so. */
|
|
126
|
+
function TextCell({ row, labels, clamp }: { row: TranslationRow; labels: TranslationReviewLabels; clamp?: boolean }) {
|
|
127
|
+
return row.text === "" ? (
|
|
128
|
+
<span className="italic text-[var(--text-muted)]">{labels.missingText}</span>
|
|
129
|
+
) : (
|
|
130
|
+
<span lang={row.locale} className={cn("whitespace-pre-line break-words", clamp && "line-clamp-3")}>
|
|
131
|
+
{row.text}
|
|
132
|
+
</span>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The page body for one locale: progress, filters (status, source, namespace, search,
|
|
138
|
+
* placeholder problems), the strings with an editor that unfolds under each, and the
|
|
139
|
+
* bulk actions over a selection.
|
|
140
|
+
*
|
|
141
|
+
* The status filter is the work queue in order — what is not there, what nobody has
|
|
142
|
+
* read, what changed after it was read, what was sent back, what is done — with each
|
|
143
|
+
* count on it. "Missing" is offered only where something is.
|
|
144
|
+
*
|
|
145
|
+
* Bulk approve takes the selected rows that are not approved yet and have a text:
|
|
146
|
+
* approving an absent string says nothing, and re-approving one says it again. On a
|
|
147
|
+
* phone the table has no checkboxes, so "Select all shown" selects what the filters
|
|
148
|
+
* show — filter to `Unreviewed` in one area, read, select, approve.
|
|
149
|
+
*/
|
|
150
|
+
export function TranslationReviewPanel({
|
|
151
|
+
rows: rowsProp,
|
|
152
|
+
localeLabel,
|
|
153
|
+
referenceLabel,
|
|
154
|
+
onSave,
|
|
155
|
+
onClear,
|
|
156
|
+
readOnly = false,
|
|
157
|
+
areas,
|
|
158
|
+
areaLabels,
|
|
159
|
+
inArea,
|
|
160
|
+
sourceLabels,
|
|
161
|
+
filter: filterProp,
|
|
162
|
+
onFilterChange,
|
|
163
|
+
progress = true,
|
|
164
|
+
pageSize = 50,
|
|
165
|
+
storageKey,
|
|
166
|
+
formatDate,
|
|
167
|
+
formatError,
|
|
168
|
+
className,
|
|
169
|
+
labels: labelsProp,
|
|
170
|
+
}: TranslationReviewPanelProps) {
|
|
171
|
+
const labels = useKitLabels("translationReview", DEFAULT_TRANSLATION_REVIEW_LABELS, labelsProp);
|
|
172
|
+
const locale = useKitLocale();
|
|
173
|
+
const editable = !readOnly && onSave !== undefined;
|
|
174
|
+
|
|
175
|
+
const [ownFilter, setOwnFilter] = useState<TranslationReviewFilter>(DEFAULT_TRANSLATION_REVIEW_FILTER);
|
|
176
|
+
// The app's fields over the panel's own; a field the app leaves `undefined` is the
|
|
177
|
+
// panel's, not a blank.
|
|
178
|
+
const filter: TranslationReviewFilter = { ...ownFilter };
|
|
179
|
+
for (const [name, value] of Object.entries(filterProp ?? {})) {
|
|
180
|
+
if (value !== undefined) Object.assign(filter, { [name]: value });
|
|
181
|
+
}
|
|
182
|
+
const [openId, setOpenId] = useState<string | null>(null);
|
|
183
|
+
const [selected, setSelected] = useState<ReadonlySet<string>>(() => new Set());
|
|
184
|
+
// One bulk or row action at a time: two writes in flight on one locale's verdicts can
|
|
185
|
+
// answer out of order. The editor keeps its own, for its own buttons.
|
|
186
|
+
const [busy, setBusy] = useState<string | null>(null);
|
|
187
|
+
const [failure, setFailure] = useState<ReactNode>(null);
|
|
188
|
+
|
|
189
|
+
const rows = useMemo(
|
|
190
|
+
() => (areas ? rowsProp.filter((row) => keyInAreas(row.key, areas, inArea)) : [...rowsProp]),
|
|
191
|
+
[rowsProp, areas, inArea],
|
|
192
|
+
);
|
|
193
|
+
const summary = useMemo(() => summariseRows(rows), [rows]);
|
|
194
|
+
const sources = useMemo(() => [...new Set(rows.map((r) => r.source))], [rows]);
|
|
195
|
+
const source = sources.includes(filter.source) ? filter.source : "all";
|
|
196
|
+
const namespaces = useMemo(
|
|
197
|
+
() => [...new Set(rows.filter((r) => source === "all" || r.source === source).map((r) => r.namespace))],
|
|
198
|
+
[rows, source],
|
|
199
|
+
);
|
|
200
|
+
const namespace = namespaces.includes(filter.namespace) ? filter.namespace : "all";
|
|
201
|
+
const mismatches = useMemo(() => rows.filter((r) => r.placeholderMismatch).length, [rows]);
|
|
202
|
+
// `filter` is rebuilt every render; its fields are what the list depends on.
|
|
203
|
+
const { status, query, placeholdersOnly } = filter;
|
|
204
|
+
const visible = useMemo(
|
|
205
|
+
() => filterTranslationRows(rows, { status, source, namespace, query, placeholdersOnly }),
|
|
206
|
+
[rows, status, source, namespace, query, placeholdersOnly],
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
const setFilter = (patch: Partial<TranslationReviewFilter>) => {
|
|
210
|
+
const next = { ...filter, ...patch };
|
|
211
|
+
setOwnFilter(next);
|
|
212
|
+
onFilterChange?.(next);
|
|
213
|
+
// A selection the new filter hides would be acted on unseen.
|
|
214
|
+
setSelected(new Set());
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const run = async (key: string, action: () => MaybePromise): Promise<boolean> => {
|
|
218
|
+
setBusy(key);
|
|
219
|
+
setFailure(null);
|
|
220
|
+
try {
|
|
221
|
+
await action();
|
|
222
|
+
return true;
|
|
223
|
+
} catch (caught) {
|
|
224
|
+
setFailure(formatError ? formatError(caught) : labels.failed);
|
|
225
|
+
return false;
|
|
226
|
+
} finally {
|
|
227
|
+
setBusy(null);
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const visibleIds = new Set(visible.map((r) => r.id));
|
|
232
|
+
const selectedRows = visible.filter((r) => selected.has(r.id));
|
|
233
|
+
const allSelected = visible.length > 0 && selectedRows.length === visible.length;
|
|
234
|
+
const toApprove = selectedRows.filter((r) => r.text !== "" && r.status !== "approved");
|
|
235
|
+
const toReset = selectedRows.filter((r) => r.review !== null);
|
|
236
|
+
|
|
237
|
+
const approveSelected = async () => {
|
|
238
|
+
if (!onSave || toApprove.length === 0) return;
|
|
239
|
+
if (await run("bulk-approve", () => onSave(toApprove.map((r) => reviewWrite(r, "APPROVED"))))) {
|
|
240
|
+
setSelected(new Set());
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
const resetSelected = async () => {
|
|
244
|
+
if (!onClear || toReset.length === 0) return;
|
|
245
|
+
if (await run("bulk-reset", () => onClear(toReset.map((r) => ({ locale: r.locale, key: r.key }))))) {
|
|
246
|
+
setSelected(new Set());
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// The status options: "missing" only where something is (or it is the filter).
|
|
251
|
+
const statuses = REVIEW_STATUSES.filter((s) => s !== "missing" || summary.missing > 0 || filter.status === s);
|
|
252
|
+
const scopeNames = (areas ?? []).map((area) => areaLabels?.[area] ?? area);
|
|
253
|
+
const scopeText =
|
|
254
|
+
scopeNames.length > 0 ? new Intl.ListFormat(locale, { type: "conjunction", style: "long" }).format(scopeNames) : "";
|
|
255
|
+
|
|
256
|
+
const columns: DataTableColumn<TranslationRow>[] = [
|
|
257
|
+
{
|
|
258
|
+
key: "key",
|
|
259
|
+
header: labels.key,
|
|
260
|
+
cell: (r) => <code className="break-all text-xs text-[var(--text-secondary)]">{r.key}</code>,
|
|
261
|
+
sortBy: (r) => r.key,
|
|
262
|
+
mobileHidden: true,
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
key: "reference",
|
|
266
|
+
header: referenceLabel,
|
|
267
|
+
cell: (r) => (
|
|
268
|
+
<span className="line-clamp-3 whitespace-pre-line break-words text-[var(--text-secondary)]">{r.reference}</span>
|
|
269
|
+
),
|
|
270
|
+
mobileHidden: true,
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
key: "text",
|
|
274
|
+
header: localeLabel,
|
|
275
|
+
cell: (r) => <TextCell row={r} labels={labels} clamp />,
|
|
276
|
+
mobilePrimary: true,
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
key: "status",
|
|
280
|
+
header: labels.statusColumn,
|
|
281
|
+
cell: (r) => (
|
|
282
|
+
<span className="inline-flex flex-wrap gap-1">
|
|
283
|
+
<ReviewStatusChip status={r.status} labels={labelsProp} />
|
|
284
|
+
{r.placeholderMismatch && (
|
|
285
|
+
<Chip size="sm" tone="danger" variant="outline">
|
|
286
|
+
{labels.placeholderChip}
|
|
287
|
+
</Chip>
|
|
288
|
+
)}
|
|
289
|
+
</span>
|
|
290
|
+
),
|
|
291
|
+
sortBy: (r) => REVIEW_STATUSES.indexOf(r.status),
|
|
292
|
+
},
|
|
293
|
+
];
|
|
294
|
+
if (editable && onSave) {
|
|
295
|
+
const save = onSave;
|
|
296
|
+
columns.push({
|
|
297
|
+
key: "approve",
|
|
298
|
+
header: <span className="sr-only">{labels.approve}</span>,
|
|
299
|
+
cell: (r) =>
|
|
300
|
+
r.status === "approved" || r.text === "" ? null : (
|
|
301
|
+
<IconButton
|
|
302
|
+
type="button"
|
|
303
|
+
size="xs"
|
|
304
|
+
tone="muted"
|
|
305
|
+
commit
|
|
306
|
+
label={labels.approve}
|
|
307
|
+
pending={busy === `row:${r.id}`}
|
|
308
|
+
disabled={busy !== null}
|
|
309
|
+
onClick={(event) => {
|
|
310
|
+
// The row's own click opens the editor; this one only approves.
|
|
311
|
+
event.stopPropagation();
|
|
312
|
+
void run(`row:${r.id}`, () => save([reviewWrite(r, "APPROVED")]));
|
|
313
|
+
}}
|
|
314
|
+
>
|
|
315
|
+
<Check />
|
|
316
|
+
</IconButton>
|
|
317
|
+
),
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return (
|
|
322
|
+
<div className={cn("min-w-0 space-y-4", className)}>
|
|
323
|
+
{scopeText && (
|
|
324
|
+
<AlertBanner tone="info" variant="inline" size="sm" block live={false}>
|
|
325
|
+
{labels.scope(scopeText)}
|
|
326
|
+
</AlertBanner>
|
|
327
|
+
)}
|
|
328
|
+
{readOnly && (
|
|
329
|
+
<AlertBanner tone="info" variant="inline" size="sm" block live={false}>
|
|
330
|
+
{labels.readOnly}
|
|
331
|
+
</AlertBanner>
|
|
332
|
+
)}
|
|
333
|
+
|
|
334
|
+
{progress && <TranslationProgress summary={summary} labels={labelsProp} />}
|
|
335
|
+
|
|
336
|
+
<ToggleGroup<ReviewStatus | "all">
|
|
337
|
+
aria-label={labels.statusFilter}
|
|
338
|
+
overflow="wrap"
|
|
339
|
+
size="sm"
|
|
340
|
+
value={filter.status}
|
|
341
|
+
onChange={(next) => setFilter({ status: next })}
|
|
342
|
+
options={[
|
|
343
|
+
{ value: "all", label: labels.filterCount(labels.all, summary.total) },
|
|
344
|
+
...statuses.map((s) => ({ value: s, label: labels.filterCount(reviewStatusLabel(labels, s), summary[s]) })),
|
|
345
|
+
]}
|
|
346
|
+
/>
|
|
347
|
+
|
|
348
|
+
<div className="flex flex-col gap-3 md:flex-row md:flex-wrap md:items-end">
|
|
349
|
+
{sources.length > 1 && (
|
|
350
|
+
<div className="md:w-48">
|
|
351
|
+
<Select label={labels.source} value={source} onChange={(e) => setFilter({ source: e.target.value })}>
|
|
352
|
+
<option value="all">{labels.allSources}</option>
|
|
353
|
+
{sources.map((s) => (
|
|
354
|
+
<option key={s} value={s}>
|
|
355
|
+
{sourceLabels?.[s] ?? s}
|
|
356
|
+
</option>
|
|
357
|
+
))}
|
|
358
|
+
</Select>
|
|
359
|
+
</div>
|
|
360
|
+
)}
|
|
361
|
+
<div className="md:w-56">
|
|
362
|
+
<Select label={labels.namespace} value={namespace} onChange={(e) => setFilter({ namespace: e.target.value })}>
|
|
363
|
+
<option value="all">{labels.allNamespaces}</option>
|
|
364
|
+
{namespaces.map((ns) => (
|
|
365
|
+
<option key={ns} value={ns}>
|
|
366
|
+
{ns}
|
|
367
|
+
</option>
|
|
368
|
+
))}
|
|
369
|
+
</Select>
|
|
370
|
+
</div>
|
|
371
|
+
<SearchField
|
|
372
|
+
className="min-w-0 md:flex-1"
|
|
373
|
+
label={labels.search}
|
|
374
|
+
value={filter.query}
|
|
375
|
+
onChange={(next) => setFilter({ query: next })}
|
|
376
|
+
/>
|
|
377
|
+
<Checkbox
|
|
378
|
+
label={labels.placeholdersOnly(mismatches)}
|
|
379
|
+
checked={filter.placeholdersOnly}
|
|
380
|
+
onCheckedChange={(next) => setFilter({ placeholdersOnly: next })}
|
|
381
|
+
/>
|
|
382
|
+
</div>
|
|
383
|
+
|
|
384
|
+
{editable && visible.length > 0 && (
|
|
385
|
+
// The phone's table has no checkboxes; this is its way into the bulk actions.
|
|
386
|
+
<Button
|
|
387
|
+
variant="ghost"
|
|
388
|
+
size="sm"
|
|
389
|
+
className="md:hidden"
|
|
390
|
+
disabled={allSelected}
|
|
391
|
+
onClick={() => setSelected(new Set(visible.map((r) => r.id)))}
|
|
392
|
+
>
|
|
393
|
+
<ListChecks className="size-4" aria-hidden />
|
|
394
|
+
{labels.selectShown}
|
|
395
|
+
</Button>
|
|
396
|
+
)}
|
|
397
|
+
|
|
398
|
+
{failure && (
|
|
399
|
+
<AlertBanner tone="danger" size="sm" role="alert">
|
|
400
|
+
{failure}
|
|
401
|
+
</AlertBanner>
|
|
402
|
+
)}
|
|
403
|
+
|
|
404
|
+
{editable && (
|
|
405
|
+
<BulkActionBar count={selectedRows.length} onClear={() => setSelected(new Set())}>
|
|
406
|
+
<Button
|
|
407
|
+
variant="primary"
|
|
408
|
+
size="sm"
|
|
409
|
+
commit
|
|
410
|
+
pending={busy === "bulk-approve"}
|
|
411
|
+
disabled={busy !== null || toApprove.length === 0}
|
|
412
|
+
onClick={() => void approveSelected()}
|
|
413
|
+
>
|
|
414
|
+
<Check className="size-4" aria-hidden />
|
|
415
|
+
{labels.approveSelected}
|
|
416
|
+
</Button>
|
|
417
|
+
{onClear && (
|
|
418
|
+
<Button
|
|
419
|
+
variant="ghost"
|
|
420
|
+
size="sm"
|
|
421
|
+
commit
|
|
422
|
+
pending={busy === "bulk-reset"}
|
|
423
|
+
disabled={busy !== null || toReset.length === 0}
|
|
424
|
+
onClick={() => void resetSelected()}
|
|
425
|
+
>
|
|
426
|
+
<RotateCcw className="size-4" aria-hidden />
|
|
427
|
+
{labels.resetSelected}
|
|
428
|
+
</Button>
|
|
429
|
+
)}
|
|
430
|
+
</BulkActionBar>
|
|
431
|
+
)}
|
|
432
|
+
|
|
433
|
+
<DataTable<TranslationRow>
|
|
434
|
+
rows={visible}
|
|
435
|
+
rowKey={(r) => r.id}
|
|
436
|
+
columns={columns}
|
|
437
|
+
empty={labels.empty}
|
|
438
|
+
defaultPageSize={pageSize}
|
|
439
|
+
storageKey={storageKey}
|
|
440
|
+
isExpanded={(r) => r.id === openId}
|
|
441
|
+
onRowClick={(r) => setOpenId((open) => (open === r.id ? null : r.id))}
|
|
442
|
+
expandedRow={(r) => (
|
|
443
|
+
<TranslationReviewEditor
|
|
444
|
+
key={r.id}
|
|
445
|
+
row={r}
|
|
446
|
+
referenceLabel={referenceLabel}
|
|
447
|
+
localeLabel={localeLabel}
|
|
448
|
+
readOnly={!editable}
|
|
449
|
+
onSave={onSave ? (write) => onSave([write]) : undefined}
|
|
450
|
+
onClear={onClear ? (key) => onClear([key]) : undefined}
|
|
451
|
+
onClose={() => setOpenId(null)}
|
|
452
|
+
formatDate={formatDate}
|
|
453
|
+
formatError={formatError}
|
|
454
|
+
labels={labelsProp}
|
|
455
|
+
/>
|
|
456
|
+
)}
|
|
457
|
+
mobileCard={(r) => (
|
|
458
|
+
<div className="min-w-0 space-y-1">
|
|
459
|
+
<code className="block break-all text-xs text-[var(--text-muted)]">{r.key}</code>
|
|
460
|
+
<div className="text-sm text-[var(--text-primary)]">
|
|
461
|
+
<TextCell row={r} labels={labels} clamp />
|
|
462
|
+
</div>
|
|
463
|
+
<div className="flex flex-wrap gap-1">
|
|
464
|
+
<ReviewStatusChip status={r.status} labels={labelsProp} />
|
|
465
|
+
{r.placeholderMismatch && (
|
|
466
|
+
<Chip size="sm" tone="danger" variant="outline">
|
|
467
|
+
{labels.placeholderChip}
|
|
468
|
+
</Chip>
|
|
469
|
+
)}
|
|
470
|
+
</div>
|
|
471
|
+
</div>
|
|
472
|
+
)}
|
|
473
|
+
selection={
|
|
474
|
+
editable
|
|
475
|
+
? {
|
|
476
|
+
isSelected: (r) => selected.has(r.id),
|
|
477
|
+
onToggle: (r, checked) =>
|
|
478
|
+
setSelected((prev) => {
|
|
479
|
+
const next = new Set([...prev].filter((id) => visibleIds.has(id)));
|
|
480
|
+
if (checked) next.add(r.id);
|
|
481
|
+
else next.delete(r.id);
|
|
482
|
+
return next;
|
|
483
|
+
}),
|
|
484
|
+
onToggleMany: (many, checked) =>
|
|
485
|
+
setSelected((prev) => {
|
|
486
|
+
const next = new Set([...prev].filter((id) => visibleIds.has(id)));
|
|
487
|
+
for (const r of many) {
|
|
488
|
+
if (checked) next.add(r.id);
|
|
489
|
+
else next.delete(r.id);
|
|
490
|
+
}
|
|
491
|
+
return next;
|
|
492
|
+
}),
|
|
493
|
+
allSelected,
|
|
494
|
+
someSelected: selectedRows.length > 0 && !allSelected,
|
|
495
|
+
onToggleAll: (checked) => setSelected(checked ? new Set(visible.map((r) => r.id)) : new Set()),
|
|
496
|
+
}
|
|
497
|
+
: undefined
|
|
498
|
+
}
|
|
499
|
+
/>
|
|
500
|
+
</div>
|
|
501
|
+
);
|
|
502
|
+
}
|
package/src/i18n/defaults.ts
CHANGED
|
@@ -47,10 +47,12 @@ import { DEFAULT_AUTHED_IMAGE_LABELS } from "../components/authed-image";
|
|
|
47
47
|
import { DEFAULT_IMAGE_GRID_LABELS } from "../components/image-grid";
|
|
48
48
|
import { DEFAULT_LIGHTBOX_LABELS } from "../components/lightbox";
|
|
49
49
|
import { DEFAULT_WRITE_LOCK_LABELS } from "../components/write-lock";
|
|
50
|
+
import { DEFAULT_LEGAL_LABELS } from "../components/legal";
|
|
50
51
|
import { DEFAULT_ACCOUNT_STATE_LABELS } from "../components/account-chips";
|
|
51
52
|
import { DEFAULT_SHARE_CARD_LABELS } from "../components/share-card";
|
|
52
53
|
import { DEFAULT_REAUTH_DIALOG_LABELS } from "../components/reauth-dialog";
|
|
53
54
|
import { DEFAULT_SERVER_WAKE_LABELS } from "../components/server-wake";
|
|
55
|
+
import { DEFAULT_TRANSLATION_REVIEW_LABELS } from "../components/translation-review-labels";
|
|
54
56
|
import {
|
|
55
57
|
DEFAULT_APP_SHELL_LABELS,
|
|
56
58
|
DEFAULT_CALCULATOR_LABELS,
|
|
@@ -138,4 +140,6 @@ export const DEFAULT_UI_KIT_LABELS: UiKitLabels = {
|
|
|
138
140
|
shareCard: DEFAULT_SHARE_CARD_LABELS,
|
|
139
141
|
reauthDialog: DEFAULT_REAUTH_DIALOG_LABELS,
|
|
140
142
|
serverWake: DEFAULT_SERVER_WAKE_LABELS,
|
|
143
|
+
translationReview: DEFAULT_TRANSLATION_REVIEW_LABELS,
|
|
144
|
+
legal: DEFAULT_LEGAL_LABELS,
|
|
141
145
|
};
|
package/src/i18n/german.ts
CHANGED
|
@@ -648,5 +648,57 @@ export function germanLabels(numberLocale: string): UiKitLabels {
|
|
|
648
648
|
waking: (appName) =>
|
|
649
649
|
`Der Server schläft ein, wenn ${appName ?? "die App"} gerade niemand benutzt. Die erste Anfrage nach einer Pause muss ihn erst wieder starten. Das kann einen Moment dauern – es geht nichts verloren, die Seite füllt sich von selbst.`,
|
|
650
650
|
},
|
|
651
|
+
legal: {
|
|
652
|
+
navLabel: "Rechtliches",
|
|
653
|
+
},
|
|
654
|
+
translationReview: {
|
|
655
|
+
statusMissing: "Fehlt",
|
|
656
|
+
statusUnreviewed: "Ungeprüft",
|
|
657
|
+
statusChanged: "Seit der Prüfung geändert",
|
|
658
|
+
statusNeedsChange: "Änderung nötig",
|
|
659
|
+
statusApproved: "Bestätigt",
|
|
660
|
+
statusFilter: "Status",
|
|
661
|
+
all: "Alle",
|
|
662
|
+
filterCount: (label, count) => `${label} · ${n(count)}`,
|
|
663
|
+
source: "Texte",
|
|
664
|
+
allSources: "Alle Texte",
|
|
665
|
+
namespace: "Bereich",
|
|
666
|
+
allNamespaces: "Alle Bereiche",
|
|
667
|
+
search: "Schlüssel und Texte durchsuchen",
|
|
668
|
+
placeholdersOnly: (count) => `Nur Platzhalter-Probleme (${n(count)})`,
|
|
669
|
+
placeholderChip: "Platzhalter",
|
|
670
|
+
key: "Schlüssel",
|
|
671
|
+
statusColumn: "Status",
|
|
672
|
+
empty: "Keine Texte passen zu diesen Filtern.",
|
|
673
|
+
missingText: "Fehlt in dieser Sprache",
|
|
674
|
+
progress: (approved, total) => `${n(approved)} von ${n(total)} bestätigt`,
|
|
675
|
+
localeProgress: (approved, total) => `${n(approved)}/${n(total)}`,
|
|
676
|
+
locales: "Sprachen",
|
|
677
|
+
approve: "Bestätigen",
|
|
678
|
+
flag: "Änderung nötig",
|
|
679
|
+
suggest: "Übersetzung vorschlagen",
|
|
680
|
+
reset: "Als ungeprüft markieren",
|
|
681
|
+
cancel: "Abbrechen",
|
|
682
|
+
approveSelected: "Auswahl bestätigen",
|
|
683
|
+
resetSelected: "Auswahl als ungeprüft markieren",
|
|
684
|
+
selectShown: "Alle angezeigten auswählen",
|
|
685
|
+
changedSince: "Dieser Text wurde nach der Prüfung geändert. Bitte lesen Sie ihn noch einmal.",
|
|
686
|
+
reviewedWording: "Wortlaut bei der Prüfung",
|
|
687
|
+
reviewedReference: "Vorlage bei der Prüfung",
|
|
688
|
+
placeholderMismatch: (reference, text) =>
|
|
689
|
+
`Die Platzhalter weichen von der Vorlage ab – Vorlage: ${reference}; dieser Text: ${text}. Die App setzt dort Werte ein, deshalb müssen sie genau so bleiben.`,
|
|
690
|
+
lastApproved: (name, date) => `Bestätigt von ${name} am ${date}`,
|
|
691
|
+
lastFlagged: (name, date) => `Als änderungsbedürftig markiert von ${name} am ${date}`,
|
|
692
|
+
// Dative, after "von": "Bestätigt von einem gelöschten Konto".
|
|
693
|
+
erasedReviewer: "einem gelöschten Konto",
|
|
694
|
+
suggestion: "Bessere Formulierung",
|
|
695
|
+
translation: "Übersetzung",
|
|
696
|
+
note: "Notiz (optional)",
|
|
697
|
+
notePlaceholder: "Was falsch ist oder worauf zu achten ist",
|
|
698
|
+
readOnly: "Sie können diese Sprache lesen, aber nicht prüfen.",
|
|
699
|
+
scope: (areas) => `Ihre Prüfung ist beschränkt auf: ${areas}.`,
|
|
700
|
+
exportCorrections: (count) => `Korrekturen exportieren (${n(count)})`,
|
|
701
|
+
failed: "Das hat nicht geklappt. Bitte erneut versuchen.",
|
|
702
|
+
},
|
|
651
703
|
};
|
|
652
704
|
}
|
package/src/i18n/kit-labels.tsx
CHANGED
|
@@ -47,10 +47,12 @@ import type { AuthedImageLabels } from "../components/authed-image";
|
|
|
47
47
|
import type { ImageGridLabels } from "../components/image-grid";
|
|
48
48
|
import type { LightboxLabels } from "../components/lightbox";
|
|
49
49
|
import type { WriteLockLabels } from "../components/write-lock";
|
|
50
|
+
import type { LegalLabels } from "../components/legal";
|
|
50
51
|
import type { AccountStateLabels } from "../components/account-chips";
|
|
51
52
|
import type { ShareCardLabels } from "../components/share-card";
|
|
52
53
|
import type { ReauthDialogLabels } from "../components/reauth-dialog";
|
|
53
54
|
import type { ServerWakeLabels } from "../components/server-wake";
|
|
55
|
+
import type { TranslationReviewLabels } from "../components/translation-review-labels";
|
|
54
56
|
|
|
55
57
|
/**
|
|
56
58
|
* EVERY string the kit renders, as one typed tree — and an optional provider that
|
|
@@ -287,6 +289,11 @@ export interface UiKitLabels {
|
|
|
287
289
|
reauthDialog: ReauthDialogLabels;
|
|
288
290
|
/** 0.18.0: `ServerWakeNotice` — keksdose's cold-start notice, for every app. */
|
|
289
291
|
serverWake: ServerWakeLabels;
|
|
292
|
+
/** 0.19.0: the translation-review parts (`TranslationReviewPanel`, its editor, chip,
|
|
293
|
+
* progress, locale tabs and export) — keksdose's /translations, for every app. */
|
|
294
|
+
translationReview: TranslationReviewLabels;
|
|
295
|
+
/** 0.19.0: `LegalLinks`' navigation name — the legal pages' shell, for every app. */
|
|
296
|
+
legal: LegalLabels;
|
|
290
297
|
}
|
|
291
298
|
|
|
292
299
|
/**
|