Email for professionals and teams
Translate MFA, API keys, avatar settings
Hieu Nguyen (Jack)e6728d6a5777
diff --git a/src/components/settings/api-keys-settings-utils.ts b/src/components/settings/api-keys-settings-utils.tsindex 0569e07..02a01f1 100644--- a/src/components/settings/api-keys-settings-utils.ts+++ b/src/components/settings/api-keys-settings-utils.ts@@ -1,21 +1,22 @@+import type { TranslationKey } from "@/lib/i18n/types";import { authFetch } from "@/lib/auth/client";import type { ApiKeyScope } from "@/lib/api/scopes";import type { ManagedApiKey, McpKeyScope } from "./api-keys-settings-types";-export const MCP_KEY_SCOPES: { value: McpKeyScope; label: string; description: string }[] = [- { value: "mcp:read", label: "Read mail", description: "List, search, and read messages." },- { value: "mcp:draft", label: "Manage drafts", description: "Create, edit, and discard drafts." },- { value: "mcp:organize", label: "Organize mail", description: "Mark messages read and move them." },- { value: "mcp:request-send", label: "Request send review", description: "Propose a send that you must confirm in Mailflare." },- { value: "mcp:calendar-read", label: "Read calendar", description: "List, search, and inspect events and free time." },- { value: "mcp:calendar-write", label: "Manage calendar", description: "Create, update, and delete events." },+export const MCP_KEY_SCOPES: { value: McpKeyScope; labelKey: TranslationKey; descriptionKey: TranslationKey }[] = [+ { value: "mcp:read", labelKey: "apiKeys.mcpRead.label", descriptionKey: "apiKeys.mcpRead.description" },+ { value: "mcp:draft", labelKey: "apiKeys.mcpDraft.label", descriptionKey: "apiKeys.mcpDraft.description" },+ { value: "mcp:organize", labelKey: "apiKeys.mcpOrganize.label", descriptionKey: "apiKeys.mcpOrganize.description" },+ { value: "mcp:request-send", labelKey: "apiKeys.mcpRequestSend.label", descriptionKey: "apiKeys.mcpRequestSend.description" },+ { value: "mcp:calendar-read", labelKey: "apiKeys.mcpCalendarRead.label", descriptionKey: "apiKeys.mcpCalendarRead.description" },+ { value: "mcp:calendar-write", labelKey: "apiKeys.mcpCalendarWrite.label", descriptionKey: "apiKeys.mcpCalendarWrite.description" },];-export const STANDARD_KEY_SCOPES: { value: ApiKeyScope; label: string; description: string }[] = [- { value: "read", label: "Read mail", description: "Read messages through the API." },- { value: "send", label: "Send mail", description: "Send messages directly through the API." },- { value: "calendar:read", label: "Read calendar", description: "Read your calendar events through the API." },- { value: "calendar:write", label: "Manage calendar", description: "Create, update, and delete your calendar events through the API." },+export const STANDARD_KEY_SCOPES: { value: ApiKeyScope; labelKey: TranslationKey; descriptionKey: TranslationKey }[] = [+ { value: "read", labelKey: "apiKeys.read.label", descriptionKey: "apiKeys.read.description" },+ { value: "send", labelKey: "apiKeys.send.label", descriptionKey: "apiKeys.send.description" },+ { value: "calendar:read", labelKey: "apiKeys.calendarRead.label", descriptionKey: "apiKeys.calendarRead.description" },+ { value: "calendar:write", labelKey: "apiKeys.calendarWrite.label", descriptionKey: "apiKeys.calendarWrite.description" },];async function responseData(response: Response): Promise<{ error?: unknown; key?: string; apiKeys?: ManagedApiKey[] }> {diff --git a/src/components/settings/api-keys-settings.tsx b/src/components/settings/api-keys-settings.tsxindex b9c7a66..ef55cff 100644--- a/src/components/settings/api-keys-settings.tsx+++ b/src/components/settings/api-keys-settings.tsx@@ -3,6 +3,7 @@import { mobilePrimaryActionAboveNavClass } from "@/components/page-header-utils";import { useEffect, useState } from "react";import { Copy, KeyRound, Plus, Trash2 } from "lucide-react";+import { useLanguage } from "@/components/language-provider";import { useSelectedMailbox } from "@/components/mailbox-provider";import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";@@ -19,6 +20,7 @@ import type { ManagedApiKey, McpKeyScope } from "./api-keys-settings-types";import { createManagedApiKey, keyPermissions, loadManagedApiKeys, MCP_KEY_SCOPES, revokeManagedApiKey, STANDARD_KEY_SCOPES } from "./api-keys-settings-utils";export function ApiKeysSettings() {+ const { t } = useLanguage();const { mailboxes, selectedMailbox } = useSelectedMailbox();const [keys, setKeys] = useState<ManagedApiKey[]>([]);const [loading, setLoading] = useState(true);@@ -37,11 +39,11 @@ export function ApiKeysSettings() {useEffect(() => {let cancelled = false;- const refresh = () => void loadManagedApiKeys().then((items) => { if (!cancelled) { setKeys(items); setError(null); } }).catch((cause) => { if (!cancelled) setError(cause instanceof Error ? cause.message : "Could not load API keys"); }).finally(() => { if (!cancelled) setLoading(false); });+ const refresh = () => void loadManagedApiKeys().then((items) => { if (!cancelled) { setKeys(items); setError(null); } }).catch((cause) => { if (!cancelled) setError(cause instanceof Error ? cause.message : t("apiKeys.loadFailed")); }).finally(() => { if (!cancelled) setLoading(false); });refresh();window.addEventListener("mailflare:api-keys-changed", refresh);return () => { cancelled = true; window.removeEventListener("mailflare:api-keys-changed", refresh); };- }, []);+ }, [t]);async function create(event: React.FormEvent) {event.preventDefault();@@ -55,57 +57,57 @@ export function ApiKeysSettings() {setName("");setKeys(await loadManagedApiKeys());} catch (cause) {- setError(cause instanceof Error ? cause.message : "Could not create API key");+ setError(cause instanceof Error ? cause.message : t("apiKeys.createFailed"));} finally { setBusy(false); }}async function revoke(key: ManagedApiKey) {- if (!window.confirm(`Revoke “${key.name}”? Apps using this key will lose access immediately.`)) return;+ if (!window.confirm(t("apiKeys.revokeConfirm", { name: key.name }))) return;setRevokingId(key.id);setError(null);try {await revokeManagedApiKey(key.id);setKeys((current) => current.filter((item) => item.id !== key.id));} catch (cause) {- setError(cause instanceof Error ? cause.message : "Could not revoke API key");+ setError(cause instanceof Error ? cause.message : t("apiKeys.revokeFailed"));} finally { setRevokingId(null); }}return <div className="space-y-6"><div className="flex items-center justify-between gap-4">- <h1 className="text-2xl md:text-3xl font-medium">API keys</h1>+ <h1 className="text-2xl md:text-3xl font-medium">{t("apiKeys.title")}</h1><Dialog open={createOpen} onOpenChange={(open) => { if (busy) return; setCreateOpen(open); setError(null); if (open && mailboxIds.length === 0) setMailboxIds([selectedMailbox?.id ?? mailboxes[0]?.id].filter((id): id is string => !!id)); if (!open) { setNewKey(null); setCopied(false); } }}>- <DialogTrigger asChild><Button type="button" className={mobilePrimaryActionAboveNavClass}><Plus className="h-4 w-4" />New API key</Button></DialogTrigger>+ <DialogTrigger asChild><Button type="button" className={mobilePrimaryActionAboveNavClass}><Plus className="h-4 w-4" />{t("apiKeys.new")}</Button></DialogTrigger><DialogContent className="max-h-[calc(100vh-4rem)] overflow-y-auto">- <DialogHeader><DialogTitle>{newKey ? "API key created" : "Create API key"}</DialogTitle><DialogDescription>{newKey ? "Copy this key now. It will only be shown once." : "Name your key and choose the access it needs."}</DialogDescription></DialogHeader>+ <DialogHeader><DialogTitle>{newKey ? t("apiKeys.createdTitle") : t("apiKeys.createTitle")}</DialogTitle><DialogDescription>{newKey ? t("apiKeys.copyNow") : t("apiKeys.nameAndAccess")}</DialogDescription></DialogHeader>{!newKey && <form onSubmit={(event) => void create(event)} className="space-y-4">- <div className="space-y-2"><Label htmlFor="managed-key-name">Key name</Label><Input id="managed-key-name" value={name} onChange={(event) => setName(event.target.value)} maxLength={100} placeholder="My integration" /></div>- <label className="flex items-start gap-3 text-sm"><Checkbox checked={mcpAllowed} onChange={(event) => setMcpAllowed(event.target.checked)} /><span><strong>Allow MCP access</strong><span className="mt-1 block text-neutral-500">Use this key with an MCP client. Sending still needs your confirmation in Mailflare.</span></span></label>- <label className={`flex items-start gap-3 text-sm ${mcpAllowed ? "opacity-50" : ""}`}><Checkbox checked={!mcpAllowed && standardScopes.includes("jmap")} disabled={mcpAllowed} onChange={(event) => setStandardScopes((current) => event.target.checked ? [...current, "jmap"] : current.filter((scope) => scope !== "jmap"))} /><span><strong>Allow JMAP access</strong><span className="mt-1 block text-neutral-500">{mcpAllowed ? "JMAP access requires a separate standard API key." : "Read and send mail from a JMAP client."}</span></span></label>- <fieldset className="space-y-2"><legend className="text-sm font-medium">Permissions</legend>{(mcpAllowed ? MCP_KEY_SCOPES : STANDARD_KEY_SCOPES).map((scope) => <label key={scope.value} className="flex items-start gap-3 py-2 text-sm"><Checkbox checked={mcpAllowed ? mcpScopes.includes(scope.value as McpKeyScope) : standardScopes.includes(scope.value as ApiKeyScope)} onChange={(event) => { if (mcpAllowed) setMcpScopes((current) => event.target.checked ? [...current, scope.value as McpKeyScope] : current.filter((item) => item !== scope.value)); else setStandardScopes((current) => event.target.checked ? [...current, scope.value as ApiKeyScope] : current.filter((item) => item !== scope.value)); }} /><span><strong>{scope.label}</strong><span className="block text-neutral-500">{scope.description}</span></span></label>)}</fieldset>- <fieldset className="space-y-2"><legend className="text-sm font-medium">Allowed mailboxes</legend>{mailboxes.length === 0 ? <p className="text-sm text-neutral-500">No accessible mailboxes.</p> : mailboxes.map((mailbox) => <label key={mailbox.id} className="flex items-center gap-3 text-sm"><Checkbox checked={mailboxIds.includes(mailbox.id)} onChange={(event) => setMailboxIds((current) => event.target.checked ? [...current, mailbox.id] : current.filter((id) => id !== mailbox.id))} />{mailbox.localPart}@{mailbox.hostname}</label>)}<p className="text-xs text-neutral-500">Aliases share their parent mailbox and are included with it.</p></fieldset>- <Button type="submit" disabled={busy || !name.trim() || (!mailboxIds.length && (mcpAllowed ? mcpScopes.some((scope) => !scope.startsWith("mcp:calendar-")) : standardScopes.some((scope) => !scope.startsWith("calendar:")))) || (mcpAllowed ? !mcpScopes.length : !standardScopes.length)}><KeyRound className="h-4 w-4" />{busy ? "Creating…" : "Create API key"}</Button>+ <div className="space-y-2"><Label htmlFor="managed-key-name">{t("apiKeys.keyName")}</Label><Input id="managed-key-name" value={name} onChange={(event) => setName(event.target.value)} maxLength={100} placeholder={t("apiKeys.namePlaceholder")} /></div>+ <label className="flex items-start gap-3 text-sm"><Checkbox checked={mcpAllowed} onChange={(event) => setMcpAllowed(event.target.checked)} /><span><strong>{t("apiKeys.allowMcp")}</strong><span className="mt-1 block text-neutral-500">{t("apiKeys.allowMcpHint")}</span></span></label>+ <label className={`flex items-start gap-3 text-sm ${mcpAllowed ? "opacity-50" : ""}`}><Checkbox checked={!mcpAllowed && standardScopes.includes("jmap")} disabled={mcpAllowed} onChange={(event) => setStandardScopes((current) => event.target.checked ? [...current, "jmap"] : current.filter((scope) => scope !== "jmap"))} /><span><strong>{t("apiKeys.allowJmap")}</strong><span className="mt-1 block text-neutral-500">{mcpAllowed ? t("apiKeys.jmapNeedsStandard") : t("apiKeys.jmapHint")}</span></span></label>+ <fieldset className="space-y-2"><legend className="text-sm font-medium">{t("apiKeys.permissions")}</legend>{(mcpAllowed ? MCP_KEY_SCOPES : STANDARD_KEY_SCOPES).map((scope) => <label key={scope.value} className="flex items-start gap-3 py-2 text-sm"><Checkbox checked={mcpAllowed ? mcpScopes.includes(scope.value as McpKeyScope) : standardScopes.includes(scope.value as ApiKeyScope)} onChange={(event) => { if (mcpAllowed) setMcpScopes((current) => event.target.checked ? [...current, scope.value as McpKeyScope] : current.filter((item) => item !== scope.value)); else setStandardScopes((current) => event.target.checked ? [...current, scope.value as ApiKeyScope] : current.filter((item) => item !== scope.value)); }} /><span><strong>{t(scope.labelKey)}</strong><span className="block text-neutral-500">{t(scope.descriptionKey)}</span></span></label>)}</fieldset>+ <fieldset className="space-y-2"><legend className="text-sm font-medium">{t("apiKeys.allowedMailboxes")}</legend>{mailboxes.length === 0 ? <p className="text-sm text-neutral-500">{t("apiKeys.noMailboxes")}</p> : mailboxes.map((mailbox) => <label key={mailbox.id} className="flex items-center gap-3 text-sm"><Checkbox checked={mailboxIds.includes(mailbox.id)} onChange={(event) => setMailboxIds((current) => event.target.checked ? [...current, mailbox.id] : current.filter((id) => id !== mailbox.id))} />{mailbox.localPart}@{mailbox.hostname}</label>)}<p className="text-xs text-neutral-500">{t("apiKeys.aliasHint")}</p></fieldset>+ <Button type="submit" disabled={busy || !name.trim() || (!mailboxIds.length && (mcpAllowed ? mcpScopes.some((scope) => !scope.startsWith("mcp:calendar-")) : standardScopes.some((scope) => !scope.startsWith("calendar:")))) || (mcpAllowed ? !mcpScopes.length : !standardScopes.length)}><KeyRound className="h-4 w-4" />{busy ? t("apiKeys.creating") : t("apiKeys.createTitle")}</Button></form>}- {newKey && <div className="space-y-3 rounded-xl border border-blue-200 bg-blue-50 p-4"><code className="block break-all rounded bg-white p-2 text-xs">{newKey}</code>{createdMcpAllowed && <McpAgentInstructions mode="mail" apiKey={newKey} />}<div className="flex gap-2"><Button type="button" size="sm" variant="outline" onClick={() => void navigator.clipboard.writeText(newKey).then(() => setCopied(true))}><Copy className="h-4 w-4" />{copied ? "Copied" : "Copy key"}</Button><Button type="button" size="sm" variant="ghost" disabled={busy} onClick={() => { setCreateOpen(false); setNewKey(null); setCopied(false); }}>Done</Button></div></div>}+ {newKey && <div className="space-y-3 rounded-xl border border-blue-200 bg-blue-50 p-4"><code className="block break-all rounded bg-white p-2 text-xs">{newKey}</code>{createdMcpAllowed && <McpAgentInstructions mode="mail" apiKey={newKey} />}<div className="flex gap-2"><Button type="button" size="sm" variant="outline" onClick={() => void navigator.clipboard.writeText(newKey).then(() => setCopied(true))}><Copy className="h-4 w-4" />{copied ? t("common.copied") : t("apiKeys.copyKey")}</Button><Button type="button" size="sm" variant="ghost" disabled={busy} onClick={() => { setCreateOpen(false); setNewKey(null); setCopied(false); }}>{t("common.done")}</Button></div></div>}{error && <p role="alert" className="mt-4 text-sm text-red-600">{error}</p>}</DialogContent></Dialog></div>- <p className="text-sm text-neutral-500">Create keys for external apps, choose their permissions and mailboxes, and revoke access here.</p>+ <p className="text-sm text-neutral-500">{t("apiKeys.description")}</p>{error && !createOpen && <p role="alert" className="text-sm text-red-600">{error}</p>}<section className="space-y-3">{loading && <SectionRowSkeleton />}- {!loading && keys.length === 0 && <p className="rounded-2xl bg-white px-5 py-4 text-sm text-neutral-500">No API keys yet</p>}+ {!loading && keys.length === 0 && <p className="rounded-2xl bg-white px-5 py-4 text-sm text-neutral-500">{t("apiKeys.none")}</p>}<List>{keys.map((key) => <ListRow key={key.id} className="px-5 py-4"><span className="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-blue-100 text-blue-700"><KeyRound className="h-5 w-5" /></span><span className="min-w-0 flex-1 space-y-2"><span className="flex min-w-0 flex-wrap items-center gap-2"><strong className="truncate text-sm font-semibold text-neutral-900">{key.name}</strong>{key.kind === "mcp" && <Badge variant="outline">MCP</Badge>}</span>- <span className="block truncate no-font-mono text-sm text-neutral-500">{key.prefix}… · Created {formatUserDate(key.createdAt, { dateStyle: "short" })}{key.lastUsedAt ? ` · Last used ${formatUserDate(key.lastUsedAt, { dateStyle: "short" })}` : " · Never used"}</span>+ <span className="block truncate no-font-mono text-sm text-neutral-500">{key.prefix}… · {t("apiKeys.createdOn", { date: formatUserDate(key.createdAt, { dateStyle: "short" }) })} · {key.lastUsedAt ? t("apiKeys.lastUsed", { date: formatUserDate(key.lastUsedAt, { dateStyle: "short" }) }) : t("apiKeys.neverUsed")}</span><span className="flex flex-wrap gap-1">{keyPermissions(key).map((scope) => <Badge key={scope} variant="outline">{scope}</Badge>)}</span>- <span className="block text-xs text-neutral-500">Mailboxes: {key.mailboxScopeEnabled || key.kind === "mcp" ? key.mailboxIds.map((id) => { const mailbox = mailboxes.find((item) => item.id === id); return mailbox ? `${mailbox.localPart}@${mailbox.hostname}` : id; }).join(", ") || "None" : "All accessible mailboxes (existing key)"}</span>+ <span className="block text-xs text-neutral-500">{t("apiKeys.mailboxesLabel", { list: key.mailboxScopeEnabled || key.kind === "mcp" ? key.mailboxIds.map((id) => { const mailbox = mailboxes.find((item) => item.id === id); return mailbox ? `${mailbox.localPart}@${mailbox.hostname}` : id; }).join(", ") || t("common.none") : t("apiKeys.allAccessible") })}</span></span>- <Button type="button" size="sm" variant="outline" disabled={revokingId === key.id} onClick={() => void revoke(key)}><Trash2 className="h-4 w-4" />{revokingId === key.id ? "Revoking…" : "Revoke"}</Button>+ <Button type="button" size="sm" variant="outline" disabled={revokingId === key.id} onClick={() => void revoke(key)}><Trash2 className="h-4 w-4" />{revokingId === key.id ? t("common.revoking") : t("common.revoke")}</Button></ListRow>)}</List></section>diff --git a/src/components/settings/mfa-settings.tsx b/src/components/settings/mfa-settings.tsxindex 54d8dd6..b0205c5 100644--- a/src/components/settings/mfa-settings.tsx+++ b/src/components/settings/mfa-settings.tsx@@ -2,6 +2,7 @@import { useEffect, useState } from "react";import { Copy, ShieldCheck, ShieldOff } from "lucide-react";+import { useLanguage } from "@/components/language-provider";import { Button } from "@/components/ui/button";import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";import { Input } from "@/components/ui/input";@@ -16,6 +17,7 @@ import { beginMfaEnrollment, confirmMfaEnrollment, disableMfa, loadMfaStatus, re* asks for both factors again.*/export function MfaSettings() {+ const { t } = useLanguage();const [status, setStatus] = useState<MfaStatusResponse | null>(null);const [error, setError] = useState<string | null>(null);const [enrollOpen, setEnrollOpen] = useState(false);@@ -23,14 +25,14 @@ export function MfaSettings() {const [codesOpen, setCodesOpen] = useState(false);useEffect(() => {- loadMfaStatus().then(setStatus).catch((err) => setError(err instanceof Error ? err.message : "Failed to load"));- }, []);+ loadMfaStatus().then(setStatus).catch((err) => setError(err instanceof Error ? err.message : t("mfa.loadFailed")));+ }, [t]);async function refresh() {setStatus(await loadMfaStatus());}- if (!status) return <p className="text-sm text-neutral-500">{error ?? "Loading two-factor settings..."}</p>;+ if (!status) return <p className="text-sm text-neutral-500">{error ?? t("mfa.loading")}</p>;return (<div className="space-y-4">@@ -42,12 +44,12 @@ export function MfaSettings() {)}<div className="min-w-0 flex-1"><p className="text-sm font-medium text-neutral-900">- {status.enabled ? "Two-factor authentication is on" : "Two-factor authentication is off"}+ {status.enabled ? t("mfa.on") : t("mfa.off")}</p><p className="mt-1 text-sm text-neutral-500">{status.enabled- ? `Signing in asks for a code from your authenticator app. ${status.recoveryCodesLeft} recovery code${status.recoveryCodesLeft === 1 ? "" : "s"} left.`- : "Add a second step at sign-in using an authenticator app such as 1Password, Google Authenticator or Authy."}+ ? t("mfa.onDescription", { count: status.recoveryCodesLeft })+ : t("mfa.offDescription")}</p></div></div>@@ -55,14 +57,14 @@ export function MfaSettings() {{status.enabled ? (<><Button variant="outline" onClick={() => setCodesOpen(true)}>- New recovery codes+ {t("mfa.newRecoveryCodes")}</Button><Button variant="outline" onClick={() => setDisableOpen(true)}>- Turn off+ {t("mfa.turnOff")}</Button></>) : (- <Button onClick={() => setEnrollOpen(true)}>Turn on two-factor</Button>+ <Button onClick={() => setEnrollOpen(true)}>{t("mfa.turnOn")}</Button>)}</div>@@ -74,6 +76,7 @@ export function MfaSettings() {}function RecoveryCodesList({ codes }: { codes: string[] }) {+ const { t } = useLanguage();const [copied, setCopied] = useState(false);return (<div className="space-y-3">@@ -91,16 +94,17 @@ function RecoveryCodesList({ codes }: { codes: string[] }) {}}><Copy className="h-4 w-4" />- {copied ? "Copied" : "Copy codes"}+ {copied ? t("common.copied") : t("mfa.copyCodes")}</Button><p className="text-xs text-neutral-500">- Each code works once. Keep them somewhere safe; they are the only way in if you lose your authenticator.+ {t("mfa.codesHint")}</p></div>);}function EnrollDialog({ open, onOpenChange, onDone }: { open: boolean; onOpenChange: (open: boolean) => void; onDone: () => Promise<void> }) {+ const { t } = useLanguage();const [step, setStep] = useState<MfaDialogStep>("password");const [password, setPassword] = useState("");const [code, setCode] = useState("");@@ -130,7 +134,7 @@ function EnrollDialog({ open, onOpenChange, onDone }: { open: boolean; onOpenChasetSecret(enrollment.secret);setStep("scan");} catch (err) {- setError(err instanceof Error ? err.message : "Could not start");+ setError(err instanceof Error ? err.message : t("mfa.startFailed"));} finally {setBusy(false);}@@ -145,7 +149,7 @@ function EnrollDialog({ open, onOpenChange, onDone }: { open: boolean; onOpenChasetStep("codes");await onDone();} catch (err) {- setError(err instanceof Error ? err.message : "Could not confirm");+ setError(err instanceof Error ? err.message : t("mfa.confirmFailed"));} finally {setBusy(false);}@@ -163,44 +167,44 @@ function EnrollDialog({ open, onOpenChange, onDone }: { open: boolean; onOpenCha{step === "password" && (<form onSubmit={start} className="space-y-4"><DialogHeader>- <DialogTitle>Turn on two-factor authentication</DialogTitle>- <DialogDescription>Confirm your password to begin.</DialogDescription>+ <DialogTitle>{t("mfa.enrollTitle")}</DialogTitle>+ <DialogDescription>{t("mfa.enrollDescription")}</DialogDescription></DialogHeader><div className="space-y-2">- <Label htmlFor="mfa-password">Password</Label>+ <Label htmlFor="mfa-password">{t("common.password")}</Label><Input id="mfa-password" type="password" autoComplete="current-password" value={password} onChange={(e) => setPassword(e.target.value)} required autoFocus /></div>{error && <p className="text-sm text-red-600">{error}</p>}- <Button type="submit" disabled={busy}>{busy ? "Please wait..." : "Continue"}</Button>+ <Button type="submit" disabled={busy}>{busy ? t("common.pleaseWait") : t("common.continue")}</Button></form>)}{step === "scan" && (<form onSubmit={confirm} className="space-y-4"><DialogHeader>- <DialogTitle>Scan the code</DialogTitle>- <DialogDescription>Open your authenticator app, add an account by scanning this code, then enter the 6-digit code it shows.</DialogDescription>+ <DialogTitle>{t("mfa.scanTitle")}</DialogTitle>+ <DialogDescription>{t("mfa.scanDescription")}</DialogDescription></DialogHeader><div className="mx-auto w-48 rounded-xl border border-neutral-200 bg-white p-2" dangerouslySetInnerHTML={{ __html: qrSvg }} /><details className="text-xs text-neutral-500">- <summary className="cursor-pointer">Can't scan? Enter the key manually</summary>+ <summary className="cursor-pointer">{t("mfa.cantScan")}</summary><code className="mt-2 block break-all rounded-md bg-neutral-50 p-2 font-mono text-neutral-800">{secret}</code></details><div className="space-y-2">- <Label htmlFor="mfa-code">6-digit code</Label>+ <Label htmlFor="mfa-code">{t("mfa.sixDigitCode")}</Label><Input id="mfa-code" inputMode="numeric" autoComplete="one-time-code" value={code} onChange={(e) => setCode(e.target.value)} placeholder="123 456" required autoFocus /></div>{error && <p className="text-sm text-red-600">{error}</p>}- <Button type="submit" disabled={busy}>{busy ? "Checking..." : "Verify and turn on"}</Button>+ <Button type="submit" disabled={busy}>{busy ? t("mfa.checking") : t("mfa.verifyAndTurnOn")}</Button></form>)}{step === "codes" && (<div className="space-y-4"><DialogHeader>- <DialogTitle>Save your recovery codes</DialogTitle>- <DialogDescription>Two-factor authentication is on. Other sessions have been signed out.</DialogDescription>+ <DialogTitle>{t("mfa.saveCodesTitle")}</DialogTitle>+ <DialogDescription>{t("mfa.saveCodesDescription")}</DialogDescription></DialogHeader><RecoveryCodesList codes={recoveryCodes} />- <Button type="button" onClick={() => onOpenChange(false)}>Done</Button>+ <Button type="button" onClick={() => onOpenChange(false)}>{t("common.done")}</Button></div>)}</DialogContent>@@ -209,6 +213,7 @@ function EnrollDialog({ open, onOpenChange, onDone }: { open: boolean; onOpenCha}function DisableDialog({ open, onOpenChange, onDone }: { open: boolean; onOpenChange: (open: boolean) => void; onDone: () => Promise<void> }) {+ const { t } = useLanguage();const [password, setPassword] = useState("");const [code, setCode] = useState("");const [error, setError] = useState<string | null>(null);@@ -225,7 +230,7 @@ function DisableDialog({ open, onOpenChange, onDone }: { open: boolean; onOpenChsetPassword("");setCode("");} catch (err) {- setError(err instanceof Error ? err.message : "Could not turn off");+ setError(err instanceof Error ? err.message : t("mfa.turnOffFailed"));} finally {setBusy(false);}@@ -236,19 +241,19 @@ function DisableDialog({ open, onOpenChange, onDone }: { open: boolean; onOpenCh<DialogContent className="max-h-[calc(100vh-4rem)] overflow-y-auto sm:max-w-[480px]"><form onSubmit={submit} className="space-y-4"><DialogHeader>- <DialogTitle>Turn off two-factor authentication</DialogTitle>- <DialogDescription>Confirm your password and a current code or recovery code.</DialogDescription>+ <DialogTitle>{t("mfa.turnOffTitle")}</DialogTitle>+ <DialogDescription>{t("mfa.turnOffDescription")}</DialogDescription></DialogHeader><div className="space-y-2">- <Label htmlFor="mfa-off-password">Password</Label>+ <Label htmlFor="mfa-off-password">{t("common.password")}</Label><Input id="mfa-off-password" type="password" autoComplete="current-password" value={password} onChange={(e) => setPassword(e.target.value)} required /></div><div className="space-y-2">- <Label htmlFor="mfa-off-code">Code</Label>+ <Label htmlFor="mfa-off-code">{t("mfa.code")}</Label><Input id="mfa-off-code" inputMode="numeric" autoComplete="one-time-code" value={code} onChange={(e) => setCode(e.target.value)} required /></div>{error && <p className="text-sm text-red-600">{error}</p>}- <Button type="submit" variant="destructive" disabled={busy}>{busy ? "Please wait..." : "Turn off"}</Button>+ <Button type="submit" variant="destructive" disabled={busy}>{busy ? t("common.pleaseWait") : t("mfa.turnOff")}</Button></form></DialogContent></Dialog>@@ -256,6 +261,7 @@ function DisableDialog({ open, onOpenChange, onDone }: { open: boolean; onOpenCh}function RecoveryCodesDialog({ open, onOpenChange, onDone }: { open: boolean; onOpenChange: (open: boolean) => void; onDone: () => Promise<void> }) {+ const { t } = useLanguage();const [password, setPassword] = useState("");const [codes, setCodes] = useState<string[] | null>(null);const [error, setError] = useState<string | null>(null);@@ -270,7 +276,7 @@ function RecoveryCodesDialog({ open, onOpenChange, onDone }: { open: boolean; onsetPassword("");await onDone();} catch (err) {- setError(err instanceof Error ? err.message : "Could not generate codes");+ setError(err instanceof Error ? err.message : t("mfa.generateFailed"));} finally {setBusy(false);}@@ -288,24 +294,24 @@ function RecoveryCodesDialog({ open, onOpenChange, onDone }: { open: boolean; on{codes ? (<div className="space-y-4"><DialogHeader>- <DialogTitle>Your new recovery codes</DialogTitle>- <DialogDescription>The previous codes no longer work.</DialogDescription>+ <DialogTitle>{t("mfa.newCodesTitle")}</DialogTitle>+ <DialogDescription>{t("mfa.newCodesDescription")}</DialogDescription></DialogHeader><RecoveryCodesList codes={codes} />- <Button type="button" onClick={() => onOpenChange(false)}>Done</Button>+ <Button type="button" onClick={() => onOpenChange(false)}>{t("common.done")}</Button></div>) : (<form onSubmit={submit} className="space-y-4"><DialogHeader>- <DialogTitle>Generate new recovery codes</DialogTitle>- <DialogDescription>This replaces every existing code. Confirm your password to continue.</DialogDescription>+ <DialogTitle>{t("mfa.generateTitle")}</DialogTitle>+ <DialogDescription>{t("mfa.generateDescription")}</DialogDescription></DialogHeader><div className="space-y-2">- <Label htmlFor="rc-password">Password</Label>+ <Label htmlFor="rc-password">{t("common.password")}</Label><Input id="rc-password" type="password" autoComplete="current-password" value={password} onChange={(e) => setPassword(e.target.value)} required autoFocus /></div>{error && <p className="text-sm text-red-600">{error}</p>}- <Button type="submit" disabled={busy}>{busy ? "Please wait..." : "Generate"}</Button>+ <Button type="submit" disabled={busy}>{busy ? t("common.pleaseWait") : t("mfa.generate")}</Button></form>)}</DialogContent>diff --git a/src/components/settings/profile-avatar-form.tsx b/src/components/settings/profile-avatar-form.tsxindex 6a6a6d6..d6ca44d 100644--- a/src/components/settings/profile-avatar-form.tsx+++ b/src/components/settings/profile-avatar-form.tsx@@ -9,6 +9,7 @@ import {getProfileAvatarUrl,} from "@/lib/profile/avatar-client";import { dispatchMailboxAvatarChanged } from "@/lib/mailboxes/avatar-client";+import { useLanguage } from "@/components/language-provider";import { Input } from "@/components/ui/input";import { ProgressiveAvatarImage } from "@/components/progressive-avatar-image";import type { ProfileAvatarFormProps, ProfileAvatarSessionResponse } from "./types";@@ -23,9 +24,11 @@ import {export function ProfileAvatarForm({mailboxId,initialHasAvatar = false,- name = "Profile",+ name: nameProp,colorSeed,}: ProfileAvatarFormProps) {+ const { t } = useLanguage();+ const name = nameProp ?? t("avatar.profile");const [hasAvatar, setHasAvatar] = useState(initialHasAvatar);const [avatarUrl, setAvatarUrl] = useState(mailboxId ? `/api/mailboxes/${mailboxId}/avatar` : "/api/profile/avatar",@@ -81,7 +84,7 @@ export function ProfileAvatarForm({dispatchProfileAvatarChanged(nextAvatarUrl);}} catch (error) {- setStatus(error instanceof Error ? error.message : "Upload failed");+ setStatus(error instanceof Error ? error.message : t("avatar.uploadFailed"));setBusy(false);}}@@ -101,12 +104,12 @@ export function ProfileAvatarForm({disabled={busy}className="group relative h-24 w-24 overflow-hidden rounded-full border border-neutral-200 bg-blue-600 text-white shadow-sm outline-none ring-blue-500 transition focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-wait"style={getAvatarColorStyle(colorSeed ?? mailboxId ?? name)}- aria-label={hasAvatar ? `Change ${name} profile picture` : `Upload ${name} profile picture`}+ aria-label={hasAvatar ? t("avatar.change", { name }) : t("avatar.upload", { name })}>{hasAvatar ? (<ProgressiveAvatarImagesrc={avatarUrl}- alt={`${name} profile picture`}+ alt={t("account.profilePicture", { name })}className="h-full w-full object-cover"onError={() => setHasAvatar(false)}/>@@ -121,7 +124,7 @@ export function ProfileAvatarForm({) : (<span className="flex flex-col items-center gap-1 text-[11px] font-medium"><Camera className="h-5 w-5" />- {hasAvatar ? "Change" : "Upload"}+ {hasAvatar ? t("avatar.changeShort") : t("avatar.uploadShort")}</span>)}</span>diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.jsonindex da0113e..e0d7fcf 100644--- a/src/lib/i18n/en.json+++ b/src/lib/i18n/en.json@@ -449,5 +449,100 @@"settings.timeZone.description": "Choose the time zone used for dates, search, and scheduling. Leave blank to follow this device ({zone}).","settings.timeZone.placeholder": "Device time zone ({zone})","settings.timeZone.current": "Current time: {time}",- "settings.timeZone.save": "Save time zone"+ "settings.timeZone.save": "Save time zone",+ "common.done": "Done",+ "common.copied": "Copied",+ "common.password": "Password",+ "common.pleaseWait": "Please wait...",+ "common.continue": "Continue",+ "common.revoke": "Revoke",+ "common.revoking": "Revoking…",+ "common.none": "None",+ "mfa.loadFailed": "Failed to load",+ "mfa.loading": "Loading two-factor settings...",+ "mfa.on": "Two-factor authentication is on",+ "mfa.off": "Two-factor authentication is off",+ "mfa.onDescription.one": "Signing in asks for a code from your authenticator app. {count} recovery code left.",+ "mfa.onDescription.other": "Signing in asks for a code from your authenticator app. {count} recovery codes left.",+ "mfa.offDescription": "Add a second step at sign-in using an authenticator app such as 1Password, Google Authenticator or Authy.",+ "mfa.newRecoveryCodes": "New recovery codes",+ "mfa.turnOff": "Turn off",+ "mfa.turnOn": "Turn on two-factor",+ "mfa.copyCodes": "Copy codes",+ "mfa.codesHint": "Each code works once. Keep them somewhere safe; they are the only way in if you lose your authenticator.",+ "mfa.startFailed": "Could not start",+ "mfa.confirmFailed": "Could not confirm",+ "mfa.enrollTitle": "Turn on two-factor authentication",+ "mfa.enrollDescription": "Confirm your password to begin.",+ "mfa.scanTitle": "Scan the code",+ "mfa.scanDescription": "Open your authenticator app, add an account by scanning this code, then enter the 6-digit code it shows.",+ "mfa.cantScan": "Can't scan? Enter the key manually",+ "mfa.sixDigitCode": "6-digit code",+ "mfa.checking": "Checking...",+ "mfa.verifyAndTurnOn": "Verify and turn on",+ "mfa.saveCodesTitle": "Save your recovery codes",+ "mfa.saveCodesDescription": "Two-factor authentication is on. Other sessions have been signed out.",+ "mfa.turnOffFailed": "Could not turn off",+ "mfa.turnOffTitle": "Turn off two-factor authentication",+ "mfa.turnOffDescription": "Confirm your password and a current code or recovery code.",+ "mfa.code": "Code",+ "mfa.generateFailed": "Could not generate codes",+ "mfa.newCodesTitle": "Your new recovery codes",+ "mfa.newCodesDescription": "The previous codes no longer work.",+ "mfa.generateTitle": "Generate new recovery codes",+ "mfa.generateDescription": "This replaces every existing code. Confirm your password to continue.",+ "mfa.generate": "Generate",+ "avatar.profile": "Profile",+ "avatar.changeShort": "Change",+ "avatar.uploadShort": "Upload",+ "apiKeys.mcpRead.label": "Read mail",+ "apiKeys.mcpRead.description": "List, search, and read messages.",+ "apiKeys.mcpDraft.label": "Manage drafts",+ "apiKeys.mcpDraft.description": "Create, edit, and discard drafts.",+ "apiKeys.mcpOrganize.label": "Organize mail",+ "apiKeys.mcpOrganize.description": "Mark messages read and move them.",+ "apiKeys.mcpRequestSend.label": "Request send review",+ "apiKeys.mcpRequestSend.description": "Propose a send that you must confirm in Mailflare.",+ "apiKeys.mcpCalendarRead.label": "Read calendar",+ "apiKeys.mcpCalendarRead.description": "List, search, and inspect events and free time.",+ "apiKeys.mcpCalendarWrite.label": "Manage calendar",+ "apiKeys.mcpCalendarWrite.description": "Create, update, and delete events.",+ "apiKeys.read.label": "Read mail",+ "apiKeys.read.description": "Read messages through the API.",+ "apiKeys.send.label": "Send mail",+ "apiKeys.send.description": "Send messages directly through the API.",+ "apiKeys.calendarRead.label": "Read calendar",+ "apiKeys.calendarRead.description": "Read your calendar events through the API.",+ "apiKeys.calendarWrite.label": "Manage calendar",+ "apiKeys.calendarWrite.description": "Create, update, and delete your calendar events through the API.",+ "apiKeys.loadFailed": "Could not load API keys",+ "apiKeys.createFailed": "Could not create API key",+ "apiKeys.revokeConfirm": "Revoke “{name}”? Apps using this key will lose access immediately.",+ "apiKeys.revokeFailed": "Could not revoke API key",+ "apiKeys.title": "API keys",+ "apiKeys.new": "New API key",+ "apiKeys.createdTitle": "API key created",+ "apiKeys.createTitle": "Create API key",+ "apiKeys.copyNow": "Copy this key now. It will only be shown once.",+ "apiKeys.nameAndAccess": "Name your key and choose the access it needs.",+ "apiKeys.keyName": "Key name",+ "apiKeys.namePlaceholder": "My integration",+ "apiKeys.allowMcp": "Allow MCP access",+ "apiKeys.allowMcpHint": "Use this key with an MCP client. Sending still needs your confirmation in Mailflare.",+ "apiKeys.allowJmap": "Allow JMAP access",+ "apiKeys.jmapNeedsStandard": "JMAP access requires a separate standard API key.",+ "apiKeys.jmapHint": "Read and send mail from a JMAP client.",+ "apiKeys.permissions": "Permissions",+ "apiKeys.allowedMailboxes": "Allowed mailboxes",+ "apiKeys.noMailboxes": "No accessible mailboxes.",+ "apiKeys.aliasHint": "Aliases share their parent mailbox and are included with it.",+ "apiKeys.creating": "Creating…",+ "apiKeys.copyKey": "Copy key",+ "apiKeys.description": "Create keys for external apps, choose their permissions and mailboxes, and revoke access here.",+ "apiKeys.none": "No API keys yet",+ "apiKeys.createdOn": "Created {date}",+ "apiKeys.lastUsed": "Last used {date}",+ "apiKeys.neverUsed": "Never used",+ "apiKeys.mailboxesLabel": "Mailboxes: {list}",+ "apiKeys.allAccessible": "All accessible mailboxes (existing key)"}diff --git a/src/lib/i18n/pt-BR.json b/src/lib/i18n/pt-BR.jsonindex 82fcda6..268918b 100644--- a/src/lib/i18n/pt-BR.json+++ b/src/lib/i18n/pt-BR.json@@ -449,5 +449,100 @@"settings.timeZone.description": "Escolha o fuso horário usado para datas, pesquisa e agendamento. Deixe em branco para seguir este dispositivo ({zone}).","settings.timeZone.placeholder": "Fuso horário do dispositivo ({zone})","settings.timeZone.current": "Hora atual: {time}",- "settings.timeZone.save": "Salvar fuso horário"+ "settings.timeZone.save": "Salvar fuso horário",+ "common.done": "Concluir",+ "common.copied": "Copiado",+ "common.password": "Senha",+ "common.pleaseWait": "Aguarde...",+ "common.continue": "Continuar",+ "common.revoke": "Revogar",+ "common.revoking": "Revogando…",+ "common.none": "Nenhum",+ "mfa.loadFailed": "Falha ao carregar",+ "mfa.loading": "Carregando configurações de dois fatores...",+ "mfa.on": "A autenticação de dois fatores está ativada",+ "mfa.off": "A autenticação de dois fatores está desativada",+ "mfa.onDescription.one": "O login solicita um código do seu aplicativo autenticador. Resta {count} código de recuperação.",+ "mfa.onDescription.other": "O login solicita um código do seu aplicativo autenticador. Restam {count} códigos de recuperação.",+ "mfa.offDescription": "Adicione uma segunda etapa no login usando um aplicativo autenticador como 1Password, Google Authenticator ou Authy.",+ "mfa.newRecoveryCodes": "Novos códigos de recuperação",+ "mfa.turnOff": "Desativar",+ "mfa.turnOn": "Ativar dois fatores",+ "mfa.copyCodes": "Copiar códigos",+ "mfa.codesHint": "Cada código funciona uma única vez. Guarde-os em um lugar seguro; eles são a única forma de entrar se você perder o autenticador.",+ "mfa.startFailed": "Não foi possível iniciar",+ "mfa.confirmFailed": "Não foi possível confirmar",+ "mfa.enrollTitle": "Ativar a autenticação de dois fatores",+ "mfa.enrollDescription": "Confirme sua senha para começar.",+ "mfa.scanTitle": "Escaneie o código",+ "mfa.scanDescription": "Abra seu aplicativo autenticador, adicione uma conta escaneando este código e digite o código de 6 dígitos exibido.",+ "mfa.cantScan": "Não consegue escanear? Digite a chave manualmente",+ "mfa.sixDigitCode": "Código de 6 dígitos",+ "mfa.checking": "Verificando...",+ "mfa.verifyAndTurnOn": "Verificar e ativar",+ "mfa.saveCodesTitle": "Salve seus códigos de recuperação",+ "mfa.saveCodesDescription": "A autenticação de dois fatores está ativada. As outras sessões foram encerradas.",+ "mfa.turnOffFailed": "Não foi possível desativar",+ "mfa.turnOffTitle": "Desativar a autenticação de dois fatores",+ "mfa.turnOffDescription": "Confirme sua senha e um código atual ou código de recuperação.",+ "mfa.code": "Código",+ "mfa.generateFailed": "Não foi possível gerar os códigos",+ "mfa.newCodesTitle": "Seus novos códigos de recuperação",+ "mfa.newCodesDescription": "Os códigos anteriores não funcionam mais.",+ "mfa.generateTitle": "Gerar novos códigos de recuperação",+ "mfa.generateDescription": "Isto substitui todos os códigos existentes. Confirme sua senha para continuar.",+ "mfa.generate": "Gerar",+ "avatar.profile": "Perfil",+ "avatar.changeShort": "Alterar",+ "avatar.uploadShort": "Enviar",+ "apiKeys.mcpRead.label": "Ler e-mails",+ "apiKeys.mcpRead.description": "Listar, pesquisar e ler mensagens.",+ "apiKeys.mcpDraft.label": "Gerenciar rascunhos",+ "apiKeys.mcpDraft.description": "Criar, editar e descartar rascunhos.",+ "apiKeys.mcpOrganize.label": "Organizar e-mails",+ "apiKeys.mcpOrganize.description": "Marcar mensagens como lidas e movê-las.",+ "apiKeys.mcpRequestSend.label": "Solicitar revisão de envio",+ "apiKeys.mcpRequestSend.description": "Propor um envio que você deve confirmar no Mailflare.",+ "apiKeys.mcpCalendarRead.label": "Ler calendário",+ "apiKeys.mcpCalendarRead.description": "Listar, pesquisar e inspecionar eventos e horários livres.",+ "apiKeys.mcpCalendarWrite.label": "Gerenciar calendário",+ "apiKeys.mcpCalendarWrite.description": "Criar, atualizar e excluir eventos.",+ "apiKeys.read.label": "Ler e-mails",+ "apiKeys.read.description": "Ler mensagens pela API.",+ "apiKeys.send.label": "Enviar e-mails",+ "apiKeys.send.description": "Enviar mensagens diretamente pela API.",+ "apiKeys.calendarRead.label": "Ler calendário",+ "apiKeys.calendarRead.description": "Ler seus eventos de calendário pela API.",+ "apiKeys.calendarWrite.label": "Gerenciar calendário",+ "apiKeys.calendarWrite.description": "Criar, atualizar e excluir seus eventos de calendário pela API.",+ "apiKeys.loadFailed": "Não foi possível carregar as chaves de API",+ "apiKeys.createFailed": "Não foi possível criar a chave de API",+ "apiKeys.revokeConfirm": "Revogar “{name}”? Os aplicativos que usam esta chave perderão o acesso imediatamente.",+ "apiKeys.revokeFailed": "Não foi possível revogar a chave de API",+ "apiKeys.title": "Chaves de API",+ "apiKeys.new": "Nova chave de API",+ "apiKeys.createdTitle": "Chave de API criada",+ "apiKeys.createTitle": "Criar chave de API",+ "apiKeys.copyNow": "Copie esta chave agora. Ela será exibida somente uma vez.",+ "apiKeys.nameAndAccess": "Dê um nome à chave e escolha o acesso necessário.",+ "apiKeys.keyName": "Nome da chave",+ "apiKeys.namePlaceholder": "Minha integração",+ "apiKeys.allowMcp": "Permitir acesso MCP",+ "apiKeys.allowMcpHint": "Use esta chave com um cliente MCP. O envio ainda precisa da sua confirmação no Mailflare.",+ "apiKeys.allowJmap": "Permitir acesso JMAP",+ "apiKeys.jmapNeedsStandard": "O acesso JMAP exige uma chave de API padrão separada.",+ "apiKeys.jmapHint": "Ler e enviar e-mails de um cliente JMAP.",+ "apiKeys.permissions": "Permissões",+ "apiKeys.allowedMailboxes": "Caixas de correio permitidas",+ "apiKeys.noMailboxes": "Nenhuma caixa de correio acessível.",+ "apiKeys.aliasHint": "Os aliases compartilham a caixa de correio principal e são incluídos com ela.",+ "apiKeys.creating": "Criando…",+ "apiKeys.copyKey": "Copiar chave",+ "apiKeys.description": "Crie chaves para aplicativos externos, escolha suas permissões e caixas de correio e revogue o acesso aqui.",+ "apiKeys.none": "Nenhuma chave de API ainda",+ "apiKeys.createdOn": "Criada em {date}",+ "apiKeys.lastUsed": "Último uso em {date}",+ "apiKeys.neverUsed": "Nunca usada",+ "apiKeys.mailboxesLabel": "Caixas de correio: {list}",+ "apiKeys.allAccessible": "Todas as caixas de correio acessíveis (chave existente)"}