Skip to content

Email for professionals and teams

Translate admin API keys, branding and licenses

Hieu Nguyen (Jack)64cf4de5dfc8
diff --git a/src/app/(admin)/api-keys/page.tsx b/src/app/(admin)/api-keys/page.tsx
index 2fcd58f..16106ea 100644
--- a/src/app/(admin)/api-keys/page.tsx
+++ b/src/app/(admin)/api-keys/page.tsx
@@ -4,6 +4,7 @@ import { mobilePrimaryActionClass } from "@/components/page-header-utils";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useState } from "react";
import { Copy, KeyRound, Plus, Trash2 } from "lucide-react";
+import { useLanguage } from "@/components/language-provider";
import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
import {
@@ -26,6 +27,7 @@ import type { ApiKey } from "./types";
import { ADMIN_KEY_PERMISSIONS, parseApiKeyScopes } from "./utils";
export default function ApiKeysPage() {
+ const { t } = useLanguage();
const qc = useQueryClient();
const [name, setName] = useState("");
const [scopes, setScopes] = useState<AdminApiKeyScope[]>(["domains"]);
@@ -39,7 +41,7 @@ export default function ApiKeysPage() {
queryKey: ["admin-api-keys"],
queryFn: async () => {
const res = await authFetch("/api/admin/api-keys");
- if (!res.ok) throw new Error("Could not load admin API keys");
+ if (!res.ok) throw new Error(t("adminKeys.loadFailed"));
return (await res.json()) as { apiKeys: ApiKey[] };
},
});
@@ -52,7 +54,7 @@ export default function ApiKeysPage() {
body: JSON.stringify({ name: name.trim(), scopes, mcpAllowed }),
});
const json = (await res.json()) as { key?: string; error?: string };
- if (!res.ok || !json.key) throw new Error(typeof json.error === "string" ? json.error : "Could not create API key");
+ if (!res.ok || !json.key) throw new Error(typeof json.error === "string" ? json.error : t("apiKeys.createFailed"));
setNewKey(json.key ?? null);
setCreatedMcpAllowed(mcpAllowed);
setCopied(false);
@@ -66,7 +68,7 @@ export default function ApiKeysPage() {
const revoke = useMutation({
mutationFn: async (id: string) => {
const res = await authFetch(`/api/admin/api-keys?id=${encodeURIComponent(id)}`, { method: "DELETE" });
- if (!res.ok) throw new Error("Could not revoke admin API key");
+ if (!res.ok) throw new Error(t("adminKeys.revokeFailed"));
},
onSuccess: () => qc.invalidateQueries({ queryKey: ["admin-api-keys"] }),
});
@@ -74,27 +76,27 @@ export default function ApiKeysPage() {
return (
<div className="space-y-6">
<div className="flex items-center justify-between gap-4">
- <h1 className="text-2xl md:text-3xl font-medium">Admin API keys</h1>
+ <h1 className="text-2xl md:text-3xl font-medium">{t("admin.section.apiKeysTitle")}</h1>
<Dialog open={createOpen} onOpenChange={(open) => { if (create.isPending) return; setCreateOpen(open); if (!open) { setNewKey(null); setCopied(false); } }}>
<DialogTrigger asChild>
<Button className={mobilePrimaryActionClass}>
<Plus className="h-4 w-4" />
- New API key
+ {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>
+ <DialogTitle>{newKey ? t("apiKeys.createdTitle") : t("apiKeys.createTitle")}</DialogTitle>
+ <DialogDescription>{newKey ? t("apiKeys.copyNow") : t("apiKeys.nameAndAccess")}</DialogDescription>
</DialogHeader>
{!newKey && <div className="space-y-4">
<div className="space-y-2">
- <Label htmlFor="admin-key-name">Key name</Label>
- <Input id="admin-key-name" value={name} onChange={(e) => setName(e.target.value)} maxLength={100} placeholder="Production app" />
+ <Label htmlFor="admin-key-name">{t("apiKeys.keyName")}</Label>
+ <Input id="admin-key-name" value={name} onChange={(e) => setName(e.target.value)} maxLength={100} placeholder={t("adminKeys.namePlaceholder")} />
</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 to manage only the admin areas selected below. It cannot read or send mail.</span></span></label>
+ <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("adminKeys.allowMcpHint")}</span></span></label>
<fieldset className="space-y-2">
- <legend className="text-sm font-medium">Permissions</legend>
+ <legend className="text-sm font-medium">{t("apiKeys.permissions")}</legend>
<div className="space-y-2">
{ADMIN_KEY_PERMISSIONS.map((scope) => (
<label key={scope.value} className="flex items-start gap-3 text-sm">
@@ -109,7 +111,7 @@ export default function ApiKeysPage() {
)
}
/>
- <span><strong>{scope.label}</strong><span className="block text-neutral-500">{scope.description}</span></span>
+ <span><strong>{t(scope.labelKey)}</strong><span className="block text-neutral-500">{t(scope.descriptionKey)}</span></span>
</label>
))}
</div>
@@ -121,10 +123,10 @@ export default function ApiKeysPage() {
onClick={() => create.mutate()}
disabled={!name.trim() || scopes.length === 0 || create.isPending}
>
- {create.isPending ? "Creating..." : "Create key"}
+ {create.isPending ? t("accounts.creating") : t("adminKeys.createKey")}
</Button>
</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="admin" 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" 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="admin" 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" onClick={() => { setCreateOpen(false); setNewKey(null); setCopied(false); }}>{t("common.done")}</Button></div></div>}
</DialogContent>
</Dialog>
</div>
@@ -135,7 +137,7 @@ export default function ApiKeysPage() {
)}
{!isLoading && (data?.apiKeys ?? []).length === 0 && (
<p className="rounded-2xl bg-white px-5 py-4 text-sm text-neutral-500">
- No API keys yet
+ {t("apiKeys.none")}
</p>
)}
<List>
@@ -158,7 +160,7 @@ export default function ApiKeysPage() {
))}
</span>
</span>
- <Button type="button" size="sm" variant="outline" disabled={revoke.isPending} onClick={() => { if (window.confirm(`Revoke “${key.name}”? Apps using this key will lose access immediately.`)) revoke.mutate(key.id); }}><Trash2 className="h-4 w-4" />Revoke</Button>
+ <Button type="button" size="sm" variant="outline" disabled={revoke.isPending} onClick={() => { if (window.confirm(t("apiKeys.revokeConfirm", { name: key.name }))) revoke.mutate(key.id); }}><Trash2 className="h-4 w-4" />{t("common.revoke")}</Button>
</ListRow>
))}
</List>
diff --git a/src/app/(admin)/api-keys/utils.ts b/src/app/(admin)/api-keys/utils.ts
index b46238e..c8d5354 100644
--- a/src/app/(admin)/api-keys/utils.ts
+++ b/src/app/(admin)/api-keys/utils.ts
@@ -1,9 +1,10 @@
+import type { TranslationKey } from "@/lib/i18n/types";
import type { AdminApiKeyScope } from "@/lib/api/scopes-types";
-export const ADMIN_KEY_PERMISSIONS: { value: AdminApiKeyScope; label: string; description: string }[] = [
- { value: "domains", label: "Manage domains", description: "Add and remove domains, and manage their DNS setup." },
- { value: "accounts", label: "Manage accounts", description: "Create and update accounts. Requires a Team license." },
- { value: "mailboxes", label: "Manage mailboxes", description: "Create, update, and remove mailboxes." },
+export const ADMIN_KEY_PERMISSIONS: { value: AdminApiKeyScope; labelKey: TranslationKey; descriptionKey: TranslationKey }[] = [
+ { value: "domains", labelKey: "adminKeys.perm.domains", descriptionKey: "adminKeys.perm.domainsDesc" },
+ { value: "accounts", labelKey: "adminKeys.perm.accounts", descriptionKey: "adminKeys.perm.accountsDesc" },
+ { value: "mailboxes", labelKey: "adminKeys.perm.mailboxes", descriptionKey: "adminKeys.perm.mailboxesDesc" },
];
export function parseApiKeyScopes(scopes: string): string[] {
diff --git a/src/app/(admin)/branding/page.tsx b/src/app/(admin)/branding/page.tsx
index f286758..70458d6 100644
--- a/src/app/(admin)/branding/page.tsx
+++ b/src/app/(admin)/branding/page.tsx
@@ -2,6 +2,7 @@
import { useEffect, useRef, useState } from "react";
import { ExternalLink, ImagePlus, LockKeyhole, Palette } from "lucide-react";
+import { useLanguage } from "@/components/language-provider";
import { useBranding } from "@/components/branding-provider";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
@@ -10,6 +11,7 @@ import { Label } from "@/components/ui/label";
import { BRANDING_ICON_ACCEPT, saveBranding } from "./utils";
export default function BrandingPage() {
+ const { t } = useLanguage();
const branding = useBranding();
const [appName, setAppName] = useState(branding.appName);
const [icon, setIcon] = useState<File | null>(null);
@@ -26,17 +28,17 @@ export default function BrandingPage() {
return (
<div className="space-y-6">
<div>
- <h1 className="text-2xl md:text-3xl font-medium text-neutral-900">Branding</h1>
- <p className="mt-2 text-sm text-neutral-500">Custom branding is available with a Pro or Team license.</p>
+ <h1 className="text-2xl md:text-3xl font-medium text-neutral-900">{t("branding.title")}</h1>
+ <p className="mt-2 text-sm text-neutral-500">{t("branding.proOnly")}</p>
</div>
<Card className="rounded-3xl border-0 bg-white p-6">
<CardHeader className="py-0">
- <CardTitle className="flex items-center gap-2"><LockKeyhole className="h-5 w-5" />License required</CardTitle>
- <CardDescription>This installation continues to use the original Mailflare name, app icon, and favicon.</CardDescription>
+ <CardTitle className="flex items-center gap-2"><LockKeyhole className="h-5 w-5" />{t("branding.licenseRequired")}</CardTitle>
+ <CardDescription>{t("branding.originalNote")}</CardDescription>
</CardHeader>
<CardContent className="flex flex-col gap-3 pt-6 sm:flex-row">
- <Button asChild><a href="https://app.paymug.co/buy/mailflare-pro" target="_blank" rel="noopener noreferrer">Buy Pro · $29 <ExternalLink className="h-4 w-4" /></a></Button>
- <Button asChild variant="outline"><a href="https://app.paymug.co/buy/mailflare-team" target="_blank" rel="noopener noreferrer">Buy Team · from $249 <ExternalLink className="h-4 w-4" /></a></Button>
+ <Button asChild><a href="https://app.paymug.co/buy/mailflare-pro" target="_blank" rel="noopener noreferrer">{t("branding.buyPro")} <ExternalLink className="h-4 w-4" /></a></Button>
+ <Button asChild variant="outline"><a href="https://app.paymug.co/buy/mailflare-team" target="_blank" rel="noopener noreferrer">{t("branding.buyTeam")} <ExternalLink className="h-4 w-4" /></a></Button>
</CardContent>
</Card>
</div>
@@ -57,9 +59,9 @@ export default function BrandingPage() {
await saveBranding(appName.trim(), icon);
await branding.refreshBranding();
setIcon(null);
- setStatus("Branding updated");
+ setStatus(t("branding.updated"));
} catch (error) {
- setStatus(error instanceof Error ? error.message : "Unable to save branding");
+ setStatus(error instanceof Error ? error.message : t("branding.saveFailed"));
} finally {
setSaving(false);
}
@@ -68,30 +70,30 @@ export default function BrandingPage() {
return (
<div className="space-y-6">
<div>
- <h1 className="text-2xl md:text-3xl font-medium text-neutral-900">Branding</h1>
- <p className="mt-2 text-sm text-neutral-500">Customize the app identity shown to everyone using this installation.</p>
+ <h1 className="text-2xl md:text-3xl font-medium text-neutral-900">{t("branding.title")}</h1>
+ <p className="mt-2 text-sm text-neutral-500">{t("branding.description")}</p>
</div>
<Card className="rounded-3xl border-0 bg-white p-6">
<CardHeader className="py-0">
- <CardTitle className="flex items-center gap-2"><Palette className="h-5 w-5" />App identity</CardTitle>
- <CardDescription>The icon is also used as the browser favicon.</CardDescription>
+ <CardTitle className="flex items-center gap-2"><Palette className="h-5 w-5" />{t("branding.identity")}</CardTitle>
+ <CardDescription>{t("branding.faviconNote")}</CardDescription>
</CardHeader>
<CardContent className="pt-6">
<form onSubmit={submit} className="space-y-6">
<div className="space-y-2">
- <Label htmlFor="appName">App name</Label>
+ <Label htmlFor="appName">{t("branding.appName")}</Label>
<Input id="appName" value={appName} maxLength={60} onChange={(event) => setAppName(event.target.value)} required />
</div>
<div className="space-y-2">
- <Label>App icon</Label>
+ <Label>{t("branding.appIcon")}</Label>
<Input ref={inputRef} type="file" accept={BRANDING_ICON_ACCEPT} className="hidden" onChange={(event) => pickIcon(event.target.files?.[0] ?? null)} />
<button type="button" onClick={() => inputRef.current?.click()} className="flex items-center gap-4 rounded-2xl border border-dashed border-neutral-300 p-4 text-left hover:bg-neutral-50">
- <img src={preview ?? branding.iconUrl} alt="App icon preview" className="h-16 w-16 rounded-2xl object-cover" />
- <span className="text-sm text-neutral-600"><ImagePlus className="mb-1 h-5 w-5" />Choose PNG, JPEG, WebP, or GIF<br /><span className="text-xs text-neutral-400">Maximum 2 MB</span></span>
+ <img src={preview ?? branding.iconUrl} alt={t("branding.iconPreview")} className="h-16 w-16 rounded-2xl object-cover" />
+ <span className="text-sm text-neutral-600"><ImagePlus className="mb-1 h-5 w-5" />{t("branding.chooseImage")}<br /><span className="text-xs text-neutral-400">{t("branding.maxSize")}</span></span>
</button>
</div>
{status && <p className="text-sm text-neutral-600">{status}</p>}
- <Button type="submit" disabled={saving || !appName.trim()}>{saving ? "Saving..." : "Save branding"}</Button>
+ <Button type="submit" disabled={saving || !appName.trim()}>{saving ? t("common.saving") : t("branding.save")}</Button>
</form>
</CardContent>
</Card>
diff --git a/src/app/(admin)/licenses/license-activation.tsx b/src/app/(admin)/licenses/license-activation.tsx
index 6d5712a..5a8e38e 100644
--- a/src/app/(admin)/licenses/license-activation.tsx
+++ b/src/app/(admin)/licenses/license-activation.tsx
@@ -3,6 +3,7 @@
import { useEffect, useState } from "react";
import type { ReactNode } from "react";
import { CheckCircle2 } from "lucide-react";
+import { useLanguage } from "@/components/language-provider";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
@@ -15,6 +16,7 @@ import { formatLicensePlan, loadLicenseStatus, runLicenseAction } from "./utils"
// children is the pricing grid: the activated card goes above it, the key form below.
export function LicenseActivation({ children }: { children?: ReactNode }) {
+ const { t } = useLanguage();
const [license, setLicense] = useState<LicenseStatus | null>(null);
const [licenseKey, setLicenseKey] = useState("");
const [selectedPlan, setSelectedPlan] = useState<ActivatableLicensePlan>("pro");
@@ -29,7 +31,7 @@ export function LicenseActivation({ children }: { children?: ReactNode }) {
if (!cancelled) setLicense(nextLicense);
})
.catch((error) => {
- if (!cancelled) setStatus(error instanceof Error ? error.message : "Unable to load license status");
+ if (!cancelled) setStatus(error instanceof Error ? error.message : t("licenses.loadFailed"));
})
.finally(() => {
if (!cancelled) setLoading(false);
@@ -41,10 +43,10 @@ export function LicenseActivation({ children }: { children?: ReactNode }) {
async function submit(nextAction: LicenseAction) {
if (nextAction !== "deactivate" && !licenseKey.trim()) {
- setStatus("Enter your license key");
+ setStatus(t("licenses.enterKey"));
return;
}
- if (nextAction === "deactivate" && !window.confirm("Deactivate this license on this installation?")) return;
+ if (nextAction === "deactivate" && !window.confirm(t("licenses.deactivateConfirm"))) return;
setAction(nextAction);
setStatus(null);
@@ -52,9 +54,9 @@ export function LicenseActivation({ children }: { children?: ReactNode }) {
const nextLicense = await runLicenseAction(nextAction, licenseKey, nextAction === "activate" ? selectedPlan : undefined);
setLicense(nextLicense);
setLicenseKey("");
- setStatus(nextAction === "deactivate" ? "License deactivated" : nextAction === "validate" ? "License validated" : "License activated");
+ setStatus(nextAction === "deactivate" ? t("licenses.deactivated") : nextAction === "validate" ? t("licenses.validated") : t("licenses.activated"));
} catch (error) {
- setStatus(error instanceof Error ? error.message : "License request failed");
+ setStatus(error instanceof Error ? error.message : t("licenses.requestFailed"));
try {
setLicense(await loadLicenseStatus());
} catch {
@@ -78,12 +80,12 @@ export function LicenseActivation({ children }: { children?: ReactNode }) {
<CheckCircle2 className="h-6 w-6" />
</span>
<div className="min-w-0 flex-1">
- <CardTitle>License activated</CardTitle>
+ <CardTitle>{t("licenses.activated")}</CardTitle>
<p className="mt-2 text-sm leading-6 text-neutral-600">
- Your {formatLicensePlan(license.plan)} license is active. Licensed features are ready to use.
+ {t("licenses.activatedBody", { plan: formatLicensePlan(license.plan, t) })}
</p>
<Button type="button" variant="outline" className="mt-5" onClick={() => void submit("deactivate")} disabled={action !== null}>
- {action === "deactivate" ? "Deactivating..." : "Deactivate license"}
+ {action === "deactivate" ? t("licenses.deactivating") : t("licenses.deactivate")}
</Button>
{status && <p className="mt-3 text-sm text-neutral-500">{status}</p>}
</div>
@@ -101,13 +103,13 @@ export function LicenseActivation({ children }: { children?: ReactNode }) {
<CardContent className="space-y-5 pb-6">
{hasActivation && license && (
<p className="rounded-2xl bg-amber-50 px-4 py-3 text-sm text-amber-800">
- This license is currently {license.state}. Enter its key to validate or deactivate it.
+ {t("licenses.currentState", { state: license.state })}
</p>
)}
{!hasActivation && (
<div className="space-y-4 pt-6">
- <Label className="mb-4">Already has a license? Choose your tier</Label>
- <div className="grid grid-cols-1 gap-3 sm:grid-cols-2 mt-2" role="radiogroup" aria-label="Product">
+ <Label className="mb-4">{t("licenses.haveLicense")}</Label>
+ <div className="grid grid-cols-1 gap-3 sm:grid-cols-2 mt-2" role="radiogroup" aria-label={t("licenses.product")}>
<button
type="button"
role="radio"
@@ -121,7 +123,7 @@ export function LicenseActivation({ children }: { children?: ReactNode }) {
}`}
>
<span className="block text-xl font-semibold">Pro</span>
- <span className="mt-1 block text-xs text-neutral-500">For individual power users</span>
+ <span className="mt-1 block text-xs text-neutral-500">{t("licenses.proTag")}</span>
</button>
<button
type="button"
@@ -136,20 +138,20 @@ export function LicenseActivation({ children }: { children?: ReactNode }) {
}`}
>
<span className="block text-xl font-semibold text-neutral-900">Team</span>
- <span className="mt-1 block text-xs text-neutral-500">For teams and shared inboxes</span>
+ <span className="mt-1 block text-xs text-neutral-500">{t("licenses.teamTag")}</span>
</button>
</div>
</div>
)}
<div className="space-y-2">
- <Label htmlFor="licenseKey">License key</Label>
+ <Label htmlFor="licenseKey">{t("licenses.licenseKey")}</Label>
<Input
id="licenseKey"
type="password"
autoComplete="off"
value={licenseKey}
onChange={(event) => setLicenseKey(event.target.value)}
- placeholder="Enter your Mailflare license key"
+ placeholder={t("licenses.keyPlaceholder")}
disabled={action !== null}
/>
</div>
@@ -157,15 +159,15 @@ export function LicenseActivation({ children }: { children?: ReactNode }) {
{hasActivation ? (
<>
<Button type="button" onClick={() => void submit("validate")} disabled={action !== null}>
- {action === "validate" ? "Validating..." : "Validate license"}
+ {action === "validate" ? t("licenses.validating") : t("licenses.validate")}
</Button>
<Button type="button" variant="outline" onClick={() => void submit("deactivate")} disabled={action !== null}>
- {action === "deactivate" ? "Deactivating..." : "Deactivate"}
+ {action === "deactivate" ? t("licenses.deactivating") : t("licenses.deactivateShort")}
</Button>
</>
) : (
<Button type="button" onClick={() => void submit("activate")} disabled={action !== null}>
- {action === "activate" ? "Activating..." : "Activate"}
+ {action === "activate" ? t("licenses.activating") : t("licenses.activate")}
</Button>
)}
{status && <p className="text-sm text-neutral-500">{status}</p>}
diff --git a/src/app/(admin)/licenses/page.tsx b/src/app/(admin)/licenses/page.tsx
index 6789c46..d68c7b8 100644
--- a/src/app/(admin)/licenses/page.tsx
+++ b/src/app/(admin)/licenses/page.tsx
@@ -1,3 +1,4 @@
+import { getServerTranslator } from "@/lib/i18n/server";
import { Check, ExternalLink } from "lucide-react";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
@@ -11,14 +12,14 @@ import {
import { LicenseActivation } from "./license-activation";
import { LICENSE_PLANS } from "./utils";
-export default function LicensesPage() {
+export default async function LicensesPage() {
+ const t = await getServerTranslator();
return (
<div className="space-y-6">
<div>
- <h1 className="text-2xl md:text-3xl font-medium text-neutral-900">Licenses</h1>
+ <h1 className="text-2xl md:text-3xl font-medium text-neutral-900">{t("licenses.title")}</h1>
<p className="mt-2 text-sm text-neutral-500">
- Choose a one-time license. Each purchase includes updates released
- during the first year.
+ {t("licenses.description")}
</p>
</div>
<LicenseActivation>
@@ -48,16 +49,16 @@ export default function LicensesPage() {
)}
</p>
</div>
- <CardDescription>{plan.description}</CardDescription>
+ <CardDescription>{t(plan.descriptionKey)}</CardDescription>
</CardHeader>
<CardContent className="space-y-3 pt-6 flex flex-col flex-1 min-h-0">
- {plan.features.map((feature) => (
+ {plan.featureKeys.map((feature) => (
<p
key={feature}
className="flex gap-2 text-sm text-neutral-600"
>
<Check className="mt-0.5 h-4 w-4 shrink-0 text-green-600" />
- {feature}
+ {t(feature)}
</p>
))}
<span className="flex-1" />
@@ -67,7 +68,7 @@ export default function LicensesPage() {
target="_blank"
rel="noopener noreferrer"
>
- Get {plan.name}
+ {t("licenses.get", { plan: plan.name })}
<ExternalLink className="h-4 w-4" />
</a>
</Button>
diff --git a/src/app/(admin)/licenses/types.d.ts b/src/app/(admin)/licenses/types.d.ts
index 5c404e5..9d9208b 100644
--- a/src/app/(admin)/licenses/types.d.ts
+++ b/src/app/(admin)/licenses/types.d.ts
@@ -1,11 +1,12 @@
+import type { TranslationKey } from "@/lib/i18n/types";
import type { LucideIcon } from "lucide-react";
import type { LicenseStatus } from "@/lib/licenses/types";
export type LicensePlan = {
name: string;
price: number;
- description: string;
- features: string[];
+ descriptionKey: TranslationKey;
+ featureKeys: TranslationKey[];
icon: LucideIcon;
checkoutUrl: string;
originalPrice?: number,
diff --git a/src/app/(admin)/licenses/utils.ts b/src/app/(admin)/licenses/utils.ts
index dfc08d1..3688a19 100644
--- a/src/app/(admin)/licenses/utils.ts
+++ b/src/app/(admin)/licenses/utils.ts
@@ -1,3 +1,4 @@
+import { defaultTranslator, type Translator } from "@/lib/i18n/utils";
import { Building2, Sparkles } from "lucide-react";
import type { LicensePlan } from "./types";
import { authFetch } from "@/lib/auth/client";
@@ -10,8 +11,8 @@ export const LICENSE_PLANS: LicensePlan[] = [
name: "Pro",
price: 29,
originalPrice: 39,
- description: "A one-time license for one account, including one year of product updates.",
- features: ["Custom branding", "All future Pro features", "Keep the licensed version forever"],
+ descriptionKey: "licenses.pro.description",
+ featureKeys: ["licenses.pro.feature1", "licenses.pro.feature2", "licenses.keepVersion"],
icon: Sparkles,
checkoutUrl: "https://app.paymug.co/buy/mailflare-pro",
},
@@ -19,8 +20,8 @@ export const LICENSE_PLANS: LicensePlan[] = [
name: "Team",
price: 249,
originalPrice: 349,
- description: "A one-time multi-account license with every Pro capability",
- features: ["Everything in Pro", "Add and manage other accounts", "Shared mailbox access as available", "Keep the licensed version forever"],
+ descriptionKey: "licenses.team.description",
+ featureKeys: ["licenses.team.feature1", "licenses.team.feature2", "licenses.team.feature3", "licenses.keepVersion"],
icon: Building2,
checkoutUrl: "https://app.paymug.co/buy/mailflare-team",
},
@@ -29,7 +30,7 @@ export const LICENSE_PLANS: LicensePlan[] = [
export async function loadLicenseStatus(): Promise<NonNullable<LicenseResponse["license"]>> {
const response = await authFetch("/api/licenses");
const data = (await response.json()) as LicenseResponse;
- if (!response.ok || !data.license) throw new Error(data.error ?? "Unable to load license status");
+ if (!response.ok || !data.license) throw new Error(data.error ?? defaultTranslator("licenses.loadFailed"));
return data.license;
}
@@ -44,13 +45,13 @@ export async function runLicenseAction(
body: JSON.stringify({ licenseKey, ...(plan ? { plan } : {}) }),
});
const data = (await response.json()) as LicenseResponse;
- if (!response.ok || !data.license) throw new Error(data.error ?? "License request failed");
+ if (!response.ok || !data.license) throw new Error(data.error ?? defaultTranslator("licenses.requestFailed"));
window.dispatchEvent(new Event(LICENSE_STATUS_CHANGED_EVENT));
return data.license;
}
-export function formatLicensePlan(plan: string): string {
- return plan === "team" ? "Team" : plan === "pro" ? "Pro" : "Community";
+export function formatLicensePlan(plan: string, t: Translator = defaultTranslator): string {
+ return plan === "team" ? "Team" : plan === "pro" ? "Pro" : t("licenses.communityPlan");
}
export function formatLicenseDate(value: Date | string | null): string | null {
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index ecbb209..cbaadf4 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -1339,5 +1339,67 @@
"backups.manual": "Manual",
"backups.scheduled": "Scheduled",
"backups.download": "Download backup",
- "backups.delete": "Delete backup"
+ "backups.delete": "Delete backup",
+ "adminKeys.loadFailed": "Could not load admin API keys",
+ "adminKeys.revokeFailed": "Could not revoke admin API key",
+ "adminKeys.perm.domains": "Manage domains",
+ "adminKeys.perm.domainsDesc": "Add and remove domains, and manage their DNS setup.",
+ "adminKeys.perm.accounts": "Manage accounts",
+ "adminKeys.perm.accountsDesc": "Create and update accounts. Requires a Team license.",
+ "adminKeys.perm.mailboxes": "Manage mailboxes",
+ "adminKeys.perm.mailboxesDesc": "Create, update, and remove mailboxes.",
+ "adminKeys.namePlaceholder": "Production app",
+ "adminKeys.allowMcpHint": "Use this key with an MCP client to manage only the admin areas selected below. It cannot read or send mail.",
+ "adminKeys.createKey": "Create key",
+ "branding.title": "Branding",
+ "branding.proOnly": "Custom branding is available with a Pro or Team license.",
+ "branding.licenseRequired": "License required",
+ "branding.originalNote": "This installation continues to use the original Mailflare name, app icon, and favicon.",
+ "branding.buyPro": "Buy Pro · $29",
+ "branding.buyTeam": "Buy Team · from $249",
+ "branding.updated": "Branding updated",
+ "branding.saveFailed": "Unable to save branding",
+ "branding.description": "Customize the app identity shown to everyone using this installation.",
+ "branding.identity": "App identity",
+ "branding.faviconNote": "The icon is also used as the browser favicon.",
+ "branding.appName": "App name",
+ "branding.appIcon": "App icon",
+ "branding.iconPreview": "App icon preview",
+ "branding.chooseImage": "Choose PNG, JPEG, WebP, or GIF",
+ "branding.maxSize": "Maximum 2 MB",
+ "branding.save": "Save branding",
+ "licenses.title": "Licenses",
+ "licenses.description": "Choose a one-time license. Each purchase includes updates released during the first year.",
+ "licenses.pro.description": "A one-time license for one account, including one year of product updates.",
+ "licenses.pro.feature1": "Custom branding",
+ "licenses.pro.feature2": "All future Pro features",
+ "licenses.keepVersion": "Keep the licensed version forever",
+ "licenses.team.description": "A one-time multi-account license with every Pro capability",
+ "licenses.team.feature1": "Everything in Pro",
+ "licenses.team.feature2": "Add and manage other accounts",
+ "licenses.team.feature3": "Shared mailbox access as available",
+ "licenses.get": "Get {plan}",
+ "licenses.communityPlan": "Community",
+ "licenses.loadFailed": "Unable to load license status",
+ "licenses.requestFailed": "License request failed",
+ "licenses.enterKey": "Enter your license key",
+ "licenses.deactivateConfirm": "Deactivate this license on this installation?",
+ "licenses.deactivated": "License deactivated",
+ "licenses.validated": "License validated",
+ "licenses.activated": "License activated",
+ "licenses.activatedBody": "Your {plan} license is active. Licensed features are ready to use.",
+ "licenses.deactivating": "Deactivating...",
+ "licenses.deactivate": "Deactivate license",
+ "licenses.currentState": "This license is currently {state}. Enter its key to validate or deactivate it.",
+ "licenses.haveLicense": "Already has a license? Choose your tier",
+ "licenses.product": "Product",
+ "licenses.proTag": "For individual power users",
+ "licenses.teamTag": "For teams and shared inboxes",
+ "licenses.licenseKey": "License key",
+ "licenses.keyPlaceholder": "Enter your Mailflare license key",
+ "licenses.validating": "Validating...",
+ "licenses.validate": "Validate license",
+ "licenses.deactivateShort": "Deactivate",
+ "licenses.activating": "Activating...",
+ "licenses.activate": "Activate"
}
diff --git a/src/lib/i18n/pt-BR.json b/src/lib/i18n/pt-BR.json
index 9267168..1b1c5a2 100644
--- a/src/lib/i18n/pt-BR.json
+++ b/src/lib/i18n/pt-BR.json
@@ -1339,5 +1339,67 @@
"backups.manual": "Manual",
"backups.scheduled": "Agendado",
"backups.download": "Baixar backup",
- "backups.delete": "Excluir backup"
+ "backups.delete": "Excluir backup",
+ "adminKeys.loadFailed": "Não foi possível carregar as chaves de API de administração",
+ "adminKeys.revokeFailed": "Não foi possível revogar a chave de API de administração",
+ "adminKeys.perm.domains": "Gerenciar domínios",
+ "adminKeys.perm.domainsDesc": "Adicionar e remover domínios e gerenciar a configuração de DNS.",
+ "adminKeys.perm.accounts": "Gerenciar contas",
+ "adminKeys.perm.accountsDesc": "Criar e atualizar contas. Requer uma licença Team.",
+ "adminKeys.perm.mailboxes": "Gerenciar caixas de correio",
+ "adminKeys.perm.mailboxesDesc": "Criar, atualizar e remover caixas de correio.",
+ "adminKeys.namePlaceholder": "Aplicativo de produção",
+ "adminKeys.allowMcpHint": "Use esta chave com um cliente MCP para gerenciar apenas as áreas de administração selecionadas abaixo. Ela não pode ler nem enviar e-mails.",
+ "adminKeys.createKey": "Criar chave",
+ "branding.title": "Marca",
+ "branding.proOnly": "A marca personalizada está disponível com uma licença Pro ou Team.",
+ "branding.licenseRequired": "Licença necessária",
+ "branding.originalNote": "Esta instalação continua usando o nome, o ícone do aplicativo e o favicon originais do Mailflare.",
+ "branding.buyPro": "Comprar Pro · US$ 29",
+ "branding.buyTeam": "Comprar Team · a partir de US$ 249",
+ "branding.updated": "Marca atualizada",
+ "branding.saveFailed": "Não foi possível salvar a marca",
+ "branding.description": "Personalize a identidade do aplicativo exibida para todos que usam esta instalação.",
+ "branding.identity": "Identidade do aplicativo",
+ "branding.faviconNote": "O ícone também é usado como favicon do navegador.",
+ "branding.appName": "Nome do aplicativo",
+ "branding.appIcon": "Ícone do aplicativo",
+ "branding.iconPreview": "Pré-visualização do ícone do aplicativo",
+ "branding.chooseImage": "Escolha PNG, JPEG, WebP ou GIF",
+ "branding.maxSize": "Máximo de 2 MB",
+ "branding.save": "Salvar marca",
+ "licenses.title": "Licenças",
+ "licenses.description": "Escolha uma licença única. Cada compra inclui as atualizações lançadas durante o primeiro ano.",
+ "licenses.pro.description": "Uma licença única para uma conta, incluindo um ano de atualizações do produto.",
+ "licenses.pro.feature1": "Marca personalizada",
+ "licenses.pro.feature2": "Todos os recursos Pro futuros",
+ "licenses.keepVersion": "Mantenha a versão licenciada para sempre",
+ "licenses.team.description": "Uma licença única para várias contas com todos os recursos Pro",
+ "licenses.team.feature1": "Tudo do Pro",
+ "licenses.team.feature2": "Adicione e gerencie outras contas",
+ "licenses.team.feature3": "Acesso a caixas de correio compartilhadas, conforme disponível",
+ "licenses.get": "Obter {plan}",
+ "licenses.communityPlan": "Community",
+ "licenses.loadFailed": "Não foi possível carregar o status da licença",
+ "licenses.requestFailed": "Falha na solicitação da licença",
+ "licenses.enterKey": "Digite sua chave de licença",
+ "licenses.deactivateConfirm": "Desativar esta licença nesta instalação?",
+ "licenses.deactivated": "Licença desativada",
+ "licenses.validated": "Licença validada",
+ "licenses.activated": "Licença ativada",
+ "licenses.activatedBody": "Sua licença {plan} está ativa. Os recursos licenciados estão prontos para uso.",
+ "licenses.deactivating": "Desativando...",
+ "licenses.deactivate": "Desativar licença",
+ "licenses.currentState": "Esta licença está atualmente {state}. Digite a chave para validá-la ou desativá-la.",
+ "licenses.haveLicense": "Já tem uma licença? Escolha seu plano",
+ "licenses.product": "Produto",
+ "licenses.proTag": "Para usuários avançados individuais",
+ "licenses.teamTag": "Para equipes e caixas de entrada compartilhadas",
+ "licenses.licenseKey": "Chave de licença",
+ "licenses.keyPlaceholder": "Digite sua chave de licença do Mailflare",
+ "licenses.validating": "Validando...",
+ "licenses.validate": "Validar licença",
+ "licenses.deactivateShort": "Desativar",
+ "licenses.activating": "Ativando...",
+ "licenses.activate": "Ativar"
}