Add a Swedish interface with a per-person language switch
A small translation system (the English text is its own key, so anything without a Swedish entry stays English) and a Language switch in the user menu, saved on the account (users.language) and following the browser when no choice has been made. Swedish covers the menu, shared parts (search, tables, dialogs, relative times), the sign-in page and the everyday pages: Dashboard, Alerts, Servers, Updates, Maintenance, My work, Coming up, To do, Integrations and the display settings. Server-written messages stay English for now. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e7f23ba13f
commit
645816d5a8
168 files changed
+12142
-1422
No files matched your search
@@ -8,6 +8,7 @@ import TimeAgo from "./TimeAgo";
|
||||
import { ErrorNotice } from "./Notice";
|
||||
import ExportTableButton from "./ExportTableButton";
|
||||
import { EmptyRow, LoadingRow } from "./EmptyState";
|
||||
import { t } from "../i18n";
|
||||
|
||||
// Monday first, as a week reads; the numbers are what the server keeps (0 = Sunday).
|
||||
const DAYS: { value: number; short: string }[] = [
|
||||
@@ -158,7 +159,7 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
|
||||
}
|
||||
|
||||
async function remove(s: MaintenanceSchedule) {
|
||||
if (!(await confirmDialog({ title: "Remove recurring maintenance", message: `Remove "${s.name}"? Windows it made that haven't begun are taken back; one already under way ends on its own.`, confirmLabel: "Remove", danger: true }))) return;
|
||||
if (!(await confirmDialog({ title: t("Remove recurring maintenance"), message: `Remove "${s.name}"? Windows it made that haven't begun are taken back; one already under way ends on its own.`, confirmLabel: "Remove", danger: true }))) return;
|
||||
try {
|
||||
await api.maintenance.schedules.remove(s.id);
|
||||
toast.success(`Removed ${s.name}.`);
|
||||
@@ -174,12 +175,12 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
|
||||
return (
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">Recurring</h3>
|
||||
<h3 className="card-title">{t("Recurring")}</h3>
|
||||
<div className="card-actions">
|
||||
<ExportTableButton filename="maintenance-recurring" />
|
||||
{canEdit && !adding && (
|
||||
<button type="button" className="btn btn-sm btn-primary" onClick={() => { setError(null); setAdding(true); }}>
|
||||
Add recurring maintenance
|
||||
{t("Add recurring maintenance")}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
@@ -190,19 +191,19 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
|
||||
<div className="card-body row g-3">
|
||||
<div className="col-md-4">
|
||||
<label className="form-label" htmlFor="rec-name">
|
||||
Name
|
||||
{t("Name")}
|
||||
</label>
|
||||
<input id="rec-name" className="form-control" required maxLength={80} placeholder="e.g. Patch night" value={name} onChange={(e) => setName(e.target.value)} />
|
||||
</div>
|
||||
<div className="col-md-8">
|
||||
<label className="form-label" htmlFor="rec-reason">
|
||||
Reason (optional)
|
||||
{t("Reason (optional)")}
|
||||
</label>
|
||||
<input id="rec-reason" className="form-control" maxLength={200} placeholder="e.g. OS updates and restarts" value={reason} onChange={(e) => setReason(e.target.value)} />
|
||||
</div>
|
||||
<div className="col-12">
|
||||
<div className="form-label" id="rec-days">
|
||||
Days
|
||||
{t("Days")}
|
||||
</div>
|
||||
<div className="btn-group" role="group" aria-labelledby="rec-days">
|
||||
{DAYS.map((d) => {
|
||||
@@ -217,14 +218,14 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
|
||||
</div>
|
||||
<div className="col-sm-6 col-md-3">
|
||||
<label className="form-label" htmlFor="rec-start">
|
||||
Starts at
|
||||
{t("Starts at")}
|
||||
</label>
|
||||
<input id="rec-start" type="time" className="form-control" required value={startTime} onChange={(e) => setStartTime(e.target.value)} />
|
||||
<div className="form-hint text-secondary small mt-1">Clock in {timezone}</div>
|
||||
<div className="form-hint text-secondary small mt-1">{t("Clock in")} {timezone}</div>
|
||||
</div>
|
||||
<div className="col-sm-6 col-md-3">
|
||||
<label className="form-label" htmlFor="rec-length">
|
||||
For
|
||||
{t("For")}
|
||||
</label>
|
||||
<select id="rec-length" className="form-select" value={minutes} onChange={(e) => setMinutes(Number(e.target.value))}>
|
||||
{/* A schedule made some other way (or before these choices) keeps whatever length it has. */}
|
||||
@@ -237,7 +238,7 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
|
||||
</select>
|
||||
</div>
|
||||
<div className="col-12">
|
||||
<div className="form-label">What it covers</div>
|
||||
<div className="form-label">{t("What it covers")}</div>
|
||||
<div className="border rounded p-2" style={{ maxHeight: 220, overflowY: "auto" }}>
|
||||
{groups.map(
|
||||
(g) =>
|
||||
@@ -289,10 +290,10 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
|
||||
</div>
|
||||
<div className="card-footer d-flex gap-2">
|
||||
<button type="submit" className="btn btn-primary" disabled={busy || picked.size === 0 || days.length === 0 || name.trim() === ""}>
|
||||
{busy ? "Saving…" : editingId === null ? "Save" : "Save changes"}
|
||||
{busy ? "Saving…" : editingId === null ? t("Save") : t("Save changes")}
|
||||
</button>
|
||||
<button type="button" className="btn" onClick={closeForm}>
|
||||
Cancel
|
||||
{t("Cancel")}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -303,11 +304,11 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
|
||||
<table className="table table-vcenter card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>{t("Name")}</th>
|
||||
<th>Covers</th>
|
||||
<th>When</th>
|
||||
<th>Next</th>
|
||||
{canEdit && <th className="w-1">Actions</th>}
|
||||
<th>{t("When")}</th>
|
||||
<th>{t("Next")}</th>
|
||||
{canEdit && <th className="w-1">{t("Actions")}</th>}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -328,13 +329,13 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
|
||||
<td>
|
||||
<div className="btn-list flex-nowrap">
|
||||
<button type="button" className="btn btn-sm btn-outline-secondary" onClick={() => startEditing(s)} disabled={editingId === s.id}>
|
||||
Edit
|
||||
{t("Edit")}
|
||||
</button>
|
||||
<button type="button" className="btn btn-sm btn-outline-secondary" onClick={() => void toggle(s)}>
|
||||
{s.enabled ? "Turn off" : "Turn on"}
|
||||
{s.enabled ? t("Turn off") : t("Turn on")}
|
||||
</button>
|
||||
<button type="button" className="btn btn-sm btn-outline-danger" onClick={() => void remove(s)}>
|
||||
Remove
|
||||
{t("Remove")}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
@@ -343,7 +344,7 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
|
||||
))}
|
||||
{schedules === null && <LoadingRow colSpan={canEdit ? 5 : 4} />}
|
||||
{schedules?.length === 0 && (
|
||||
<EmptyRow colSpan={canEdit ? 5 : 4} title="No recurring maintenance" hint="Add one for the night you patch, and its windows appear a week ahead, so alerts stay quiet without anyone remembering to." action={canEdit ? { label: "Add recurring maintenance", onClick: () => { setError(null); setAdding(true); } } : undefined} />
|
||||
<EmptyRow colSpan={canEdit ? 5 : 4} title={t("No recurring maintenance")} hint={t("Add one for the night you patch, and its windows appear a week ahead, so alerts stay quiet without anyone remembering to.")} action={canEdit ? { label: "Add recurring maintenance", onClick: () => { setError(null); setAdding(true); } } : undefined} />
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Reference in new issue
Block a user