Skip to content

Email for professionals and teams

update localization to reduce sizes

Hieu Nguyen (Jack)850661ae3ef1
diff --git a/src/lib/i18n/ar.json b/public/locales/ar.json
similarity index 100%
rename from src/lib/i18n/ar.json
rename to public/locales/ar.json
diff --git a/src/lib/i18n/bn.json b/public/locales/bn.json
similarity index 100%
rename from src/lib/i18n/bn.json
rename to public/locales/bn.json
diff --git a/src/lib/i18n/de.json b/public/locales/de.json
similarity index 100%
rename from src/lib/i18n/de.json
rename to public/locales/de.json
diff --git a/src/lib/i18n/es.json b/public/locales/es.json
similarity index 100%
rename from src/lib/i18n/es.json
rename to public/locales/es.json
diff --git a/src/lib/i18n/fa.json b/public/locales/fa.json
similarity index 100%
rename from src/lib/i18n/fa.json
rename to public/locales/fa.json
diff --git a/src/lib/i18n/fr.json b/public/locales/fr.json
similarity index 100%
rename from src/lib/i18n/fr.json
rename to public/locales/fr.json
diff --git a/src/lib/i18n/gu.json b/public/locales/gu.json
similarity index 100%
rename from src/lib/i18n/gu.json
rename to public/locales/gu.json
diff --git a/src/lib/i18n/ha.json b/public/locales/ha.json
similarity index 100%
rename from src/lib/i18n/ha.json
rename to public/locales/ha.json
diff --git a/src/lib/i18n/hi.json b/public/locales/hi.json
similarity index 100%
rename from src/lib/i18n/hi.json
rename to public/locales/hi.json
diff --git a/src/lib/i18n/id.json b/public/locales/id.json
similarity index 100%
rename from src/lib/i18n/id.json
rename to public/locales/id.json
diff --git a/src/lib/i18n/it.json b/public/locales/it.json
similarity index 100%
rename from src/lib/i18n/it.json
rename to public/locales/it.json
diff --git a/src/lib/i18n/ja.json b/public/locales/ja.json
similarity index 100%
rename from src/lib/i18n/ja.json
rename to public/locales/ja.json
diff --git a/src/lib/i18n/kn.json b/public/locales/kn.json
similarity index 100%
rename from src/lib/i18n/kn.json
rename to public/locales/kn.json
diff --git a/src/lib/i18n/ko.json b/public/locales/ko.json
similarity index 100%
rename from src/lib/i18n/ko.json
rename to public/locales/ko.json
diff --git a/src/lib/i18n/ml.json b/public/locales/ml.json
similarity index 100%
rename from src/lib/i18n/ml.json
rename to public/locales/ml.json
diff --git a/src/lib/i18n/mr.json b/public/locales/mr.json
similarity index 100%
rename from src/lib/i18n/mr.json
rename to public/locales/mr.json
diff --git a/src/lib/i18n/ms.json b/public/locales/ms.json
similarity index 100%
rename from src/lib/i18n/ms.json
rename to public/locales/ms.json
diff --git a/src/lib/i18n/nl.json b/public/locales/nl.json
similarity index 100%
rename from src/lib/i18n/nl.json
rename to public/locales/nl.json
diff --git a/src/lib/i18n/pa.json b/public/locales/pa.json
similarity index 100%
rename from src/lib/i18n/pa.json
rename to public/locales/pa.json
diff --git a/src/lib/i18n/pl.json b/public/locales/pl.json
similarity index 100%
rename from src/lib/i18n/pl.json
rename to public/locales/pl.json
diff --git a/src/lib/i18n/pt-BR.json b/public/locales/pt-BR.json
similarity index 100%
rename from src/lib/i18n/pt-BR.json
rename to public/locales/pt-BR.json
diff --git a/src/lib/i18n/pt-PT.json b/public/locales/pt-PT.json
similarity index 100%
rename from src/lib/i18n/pt-PT.json
rename to public/locales/pt-PT.json
diff --git a/src/lib/i18n/ru.json b/public/locales/ru.json
similarity index 100%
rename from src/lib/i18n/ru.json
rename to public/locales/ru.json
diff --git a/src/lib/i18n/sw.json b/public/locales/sw.json
similarity index 100%
rename from src/lib/i18n/sw.json
rename to public/locales/sw.json
diff --git a/src/lib/i18n/ta.json b/public/locales/ta.json
similarity index 100%
rename from src/lib/i18n/ta.json
rename to public/locales/ta.json
diff --git a/src/lib/i18n/te.json b/public/locales/te.json
similarity index 100%
rename from src/lib/i18n/te.json
rename to public/locales/te.json
diff --git a/src/lib/i18n/th.json b/public/locales/th.json
similarity index 100%
rename from src/lib/i18n/th.json
rename to public/locales/th.json
diff --git a/src/lib/i18n/tr.json b/public/locales/tr.json
similarity index 100%
rename from src/lib/i18n/tr.json
rename to public/locales/tr.json
diff --git a/src/lib/i18n/uk.json b/public/locales/uk.json
similarity index 100%
rename from src/lib/i18n/uk.json
rename to public/locales/uk.json
diff --git a/src/lib/i18n/ur.json b/public/locales/ur.json
similarity index 100%
rename from src/lib/i18n/ur.json
rename to public/locales/ur.json
diff --git a/src/lib/i18n/vi.json b/public/locales/vi.json
similarity index 100%
rename from src/lib/i18n/vi.json
rename to public/locales/vi.json
diff --git a/src/lib/i18n/zh-CN.json b/public/locales/zh-CN.json
similarity index 100%
rename from src/lib/i18n/zh-CN.json
rename to public/locales/zh-CN.json
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index 60cf6de..9f70d38 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -862,7 +862,7 @@
"admin.section.domains": "Add Cloudflare domains and inspect DNS state.",
"admin.section.branding": "Customize the app name, icon, and favicon.",
"admin.section.licenses": "Compare Pro and Team one-time licenses.",
- "admin.section.accounts": "Add and manage user accounts with a Team license.",
+ "admin.section.accounts": "Add and manage user accounts with a Pro or Team license.",
"admin.section.apiKeys": "Manage API access to domains, accounts, and mailboxes.",
"admin.section.apiKeysTitle": "Admin API keys",
"admin.page.aiUsage": "AI usage",
@@ -876,6 +876,11 @@
"general.appliesTo": "Applies to each file and all files combined. Maximum: 25 MB; up to 10 files.",
"general.cloudflareLimit": "Cloudflare Email Sending limits the complete email, including attachments and encoding, to 5 MiB for general recipients. The 25 MiB exception applies only to verified destination addresses.",
"general.largeFiles": "Files over 3 MB, and smaller files that would make the email exceed Cloudflare’s 5 MiB limit, are stored in R2 and sent as download links. Links expire after 30 days. Anyone with a link can download the file until it expires. Set APP_URL to your public HTTPS address when sending through API or background workflows.",
+ "general.drive": "Drive storage",
+ "general.driveUnlimited": "Unlimited storage",
+ "general.driveLimit": "Storage limit per user (GB)",
+ "general.driveHint": "Each user's files in Drive count toward their own limit. Uploads that would go over it are refused; existing files are never removed.",
+ "general.driveSaved": "Drive storage limit saved",
"general.save": "Save settings",
"routingAdmin.title": "Routing",
"routingAdmin.description": "Configure domain-wide delivery, forwarding, and blocking rules.",
@@ -888,7 +893,7 @@
"accounts.checkDetails": "Check the account and alias details and try again",
"accounts.createFailed": "Unable to create account",
"accounts.title": "Accounts",
- "accounts.description": "Manage Team accounts and their inboxes.",
+ "accounts.description": "Manage accounts and their inboxes.",
"accounts.new": "New account",
"accounts.primaryAdmin": "Primary admin",
"accounts.role.admin": "admin",
@@ -1345,7 +1350,7 @@
"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.accountsDesc": "Create and update accounts. Requires a Pro or Team license.",
"adminKeys.perm.mailboxes": "Manage mailboxes",
"adminKeys.perm.mailboxesDesc": "Create, update, and remove mailboxes.",
"adminKeys.namePlaceholder": "Production app",
@@ -1370,13 +1375,13 @@
"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.description": "A one-time license with account seats you can extend, including one year of product updates.",
"licenses.pro.feature1": "Custom branding",
- "licenses.pro.feature2": "All future Pro features",
+ "licenses.pro.feature2": "Add accounts up to your license seats",
"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.feature2": "Unlimited accounts",
"licenses.team.feature3": "Shared mailbox access as available",
"licenses.get": "Get {plan}",
"licenses.communityPlan": "Community",
@@ -1387,6 +1392,10 @@
"licenses.deactivated": "License deactivated",
"licenses.validated": "License validated",
"licenses.activated": "License activated",
+ "accounts.seatsUsed": "{used} of {limit} account seats used.",
+ "accounts.seatsFull": "Disable an account or add seats to your license to create more.",
+ "licenses.seats": "Account seats: {limit}",
+ "licenses.seatsUnlimited": "Unlimited account seats",
"licenses.activatedBody": "Your {plan} license is active. Licensed features are ready to use.",
"licenses.deactivating": "Deactivating...",
"licenses.deactivate": "Deactivate license",
@@ -1861,5 +1870,98 @@
"layout.resizeMenu": "Resize left menu",
"nav.loadingPage": "Loading page",
"message.blockRemote": "Block remote content",
- "message.allowRemote": "Allow remote content"
+ "message.allowRemote": "Allow remote content",
+ "account.drive": "Drive",
+ "drive.title": "Drive",
+ "drive.new": "New",
+ "drive.newFolder": "New folder",
+ "drive.fileUpload": "File upload",
+ "drive.myDrive": "My Drive",
+ "drive.photos": "Photos",
+ "drive.videos": "Videos",
+ "drive.documents": "Documents",
+ "drive.others": "Others",
+ "drive.resizeColumn": "Resize {name} column",
+ "drive.selected": "{count} selected",
+ "drive.selectAll": "Select all",
+ "drive.selectItem": "Select {name}",
+ "drive.moveToFolder": "Move to folder",
+ "drive.newFolderPlaceholder": "New folder name",
+ "drive.createAndMove": "Create and move",
+ "drive.noFolders": "No folders yet",
+ "drive.bulkTrashed": "Moved {count} item(s) to trash",
+ "drive.bulkRestored": "Restored {count} item(s)",
+ "drive.bulkDeleted": "Deleted {count} item(s) permanently",
+ "drive.bulkMoved": "Moved {count} item(s)",
+ "drive.confirmBulkDelete": "Delete {count} item(s) forever? This cannot be undone.",
+ "drive.attachments": "Attachments",
+ "drive.emptyAttachments": "No email attachments yet",
+ "drive.folders": "Folders",
+ "drive.foldersToggle": "Show or hide folders",
+ "drive.typeFilter": "Type",
+ "drive.clearFilter": "Clear filter",
+ "drive.openEmail": "Open email",
+ "drive.from": "From",
+ "drive.storageOf": "{used} of {total} used",
+ "drive.storageBar": "Storage used",
+ "drive.trashNotice": "Items in the trash are deleted forever after {days} days. Email attachments you trash are hidden from their email until restored.",
+ "drive.folderCreated": "Folder created",
+ "drive.sharedWithMe": "Shared with me",
+ "drive.trash": "Trash",
+ "drive.sections": "Drive sections",
+ "drive.storageUsed": "{size} used",
+ "drive.search": "Search in Drive",
+ "drive.name": "Name",
+ "drive.owner": "Owner",
+ "drive.me": "me",
+ "drive.modified": "Date modified",
+ "drive.fileSize": "File size",
+ "drive.actions": "More actions",
+ "drive.open": "Open",
+ "drive.download": "Download",
+ "drive.share": "Share",
+ "drive.rename": "Rename",
+ "drive.moveToTrash": "Move to trash",
+ "drive.restore": "Restore",
+ "drive.deleteForever": "Delete forever",
+ "drive.empty": "Drop files here or use New to upload",
+ "drive.emptyShared": "Nothing has been shared with you",
+ "drive.emptyTrash": "Trash is empty",
+ "drive.emptySearch": "No files match your search",
+ "drive.loadFailed": "Could not load files.",
+ "drive.folderName": "Folder name",
+ "drive.untitledFolder": "Untitled folder",
+ "drive.create": "Create",
+ "drive.renameTitle": "Rename",
+ "drive.uploading": "Uploading {name}…",
+ "drive.resuming": "Resuming {name}…",
+ "drive.uploaded": "Uploaded {count} file(s)",
+ "drive.uploadFailed": "Could not upload {name}. Select it again to resume.",
+ "drive.tooLarge": "{name} is larger than {size}.",
+ "drive.trashed": "Moved to trash",
+ "drive.restored": "Restored",
+ "drive.deleted": "Deleted permanently",
+ "drive.actionFailed": "That did not work. Please try again.",
+ "drive.confirmDelete": "Delete \"{name}\" forever? This cannot be undone.",
+ "drive.shareTitle": "Share \"{name}\"",
+ "drive.shareEmail": "Add people by email",
+ "drive.shareAdd": "Share",
+ "drive.canView": "Can view",
+ "drive.canEdit": "Can edit",
+ "drive.remove": "Remove",
+ "drive.peopleWithAccess": "People with access",
+ "drive.noPeople": "Only you have access",
+ "drive.generalAccess": "General access",
+ "drive.linkOff": "Restricted — only people added above",
+ "drive.linkOn": "Anyone with the link can view",
+ "drive.linkEnable": "Create link",
+ "drive.linkDisable": "Turn off link",
+ "drive.copyLink": "Copy link",
+ "drive.linkCopied": "Link copied",
+ "drive.shareFailed": "Could not update sharing.",
+ "drive.preview": "Preview",
+ "drive.noPreview": "No preview available for this file type.",
+ "drive.publicNotFound": "This link is not available. It may have been turned off or the file removed.",
+ "drive.sharedBy": "Shared by {name}",
+ "drive.save": "Save"
}
diff --git a/src/lib/i18n/locales.ts b/src/lib/i18n/locales.ts
index f8000a4..f5374c4 100644
--- a/src/lib/i18n/locales.ts
+++ b/src/lib/i18n/locales.ts
@@ -1,50 +1,48 @@
-import en from "./en.json";
-
type LocaleEntry = {
/** The language's own name, shown in the selector. */
label: string;
/** Set for right-to-left scripts. */
dir?: "rtl";
- /** English ships in the main bundle as the fallback; every other catalog is fetched when first needed. */
- load: () => Promise<Record<string, string>>;
};
-// Register a language here with its native name, and add its catalog file next to `en.json`.
+// Register a language here with its native name, and add its catalog as `public/locales/<code>.json`.
+// English ships in the bundle; other catalogs are static assets fetched when first needed, so they
+// do not count toward the Worker size limit.
// Types, validation, cookies, SSR and the selector all derive from this registry.
export const locales = {
- en: { label: "English", load: async () => en },
- "pt-BR": { label: "Português (Brasil)", load: async () => (await import("./pt-BR.json")).default },
- "pt-PT": { label: "Português (Portugal)", load: async () => (await import("./pt-PT.json")).default },
- es: { label: "Español", load: async () => (await import("./es.json")).default },
- fr: { label: "Français", load: async () => (await import("./fr.json")).default },
- de: { label: "Deutsch", load: async () => (await import("./de.json")).default },
- ru: { label: "Русский", load: async () => (await import("./ru.json")).default },
- "zh-CN": { label: "中文(简体)", load: async () => (await import("./zh-CN.json")).default },
- ja: { label: "日本語", load: async () => (await import("./ja.json")).default },
- id: { label: "Bahasa Indonesia", load: async () => (await import("./id.json")).default },
- tr: { label: "Türkçe", load: async () => (await import("./tr.json")).default },
- vi: { label: "Tiếng Việt", load: async () => (await import("./vi.json")).default },
- hi: { label: "हिन्दी", load: async () => (await import("./hi.json")).default },
- ar: { label: "العربية", dir: "rtl", load: async () => (await import("./ar.json")).default },
- bn: { label: "বাংলা", load: async () => (await import("./bn.json")).default },
- ur: { label: "اردو", dir: "rtl", load: async () => (await import("./ur.json")).default },
- mr: { label: "मराठी", load: async () => (await import("./mr.json")).default },
- te: { label: "తెలుగు", load: async () => (await import("./te.json")).default },
- ko: { label: "한국어", load: async () => (await import("./ko.json")).default },
- it: { label: "Italiano", load: async () => (await import("./it.json")).default },
- ta: { label: "தமிழ்", load: async () => (await import("./ta.json")).default },
- fa: { label: "فارسی", dir: "rtl", load: async () => (await import("./fa.json")).default },
- ms: { label: "Bahasa Melayu", load: async () => (await import("./ms.json")).default },
- sw: { label: "Kiswahili", load: async () => (await import("./sw.json")).default },
- th: { label: "ไทย", load: async () => (await import("./th.json")).default },
- gu: { label: "ગુજરાતી", load: async () => (await import("./gu.json")).default },
- kn: { label: "ಕನ್ನಡ", load: async () => (await import("./kn.json")).default },
- pl: { label: "Polski", load: async () => (await import("./pl.json")).default },
- uk: { label: "Українська", load: async () => (await import("./uk.json")).default },
- nl: { label: "Nederlands", load: async () => (await import("./nl.json")).default },
- ml: { label: "മലയാളം", load: async () => (await import("./ml.json")).default },
- pa: { label: "ਪੰਜਾਬੀ", load: async () => (await import("./pa.json")).default },
- ha: { label: "Hausa", load: async () => (await import("./ha.json")).default },
+ en: { label: "English" },
+ "pt-BR": { label: "Português (Brasil)" },
+ "pt-PT": { label: "Português (Portugal)" },
+ es: { label: "Español" },
+ fr: { label: "Français" },
+ de: { label: "Deutsch" },
+ ru: { label: "Русский" },
+ "zh-CN": { label: "中文(简体)" },
+ ja: { label: "日本語" },
+ id: { label: "Bahasa Indonesia" },
+ tr: { label: "Türkçe" },
+ vi: { label: "Tiếng Việt" },
+ hi: { label: "हिन्दी" },
+ ar: { label: "العربية", dir: "rtl" },
+ bn: { label: "বাংলা" },
+ ur: { label: "اردو", dir: "rtl" },
+ mr: { label: "मराठी" },
+ te: { label: "తెలుగు" },
+ ko: { label: "한국어" },
+ it: { label: "Italiano" },
+ ta: { label: "தமிழ்" },
+ fa: { label: "فارسی", dir: "rtl" },
+ ms: { label: "Bahasa Melayu" },
+ sw: { label: "Kiswahili" },
+ th: { label: "ไทย" },
+ gu: { label: "ગુજરાતી" },
+ kn: { label: "ಕನ್ನಡ" },
+ pl: { label: "Polski" },
+ uk: { label: "Українська" },
+ nl: { label: "Nederlands" },
+ ml: { label: "മലയാളം" },
+ pa: { label: "ਪੰਜਾਬੀ" },
+ ha: { label: "Hausa" },
} satisfies Record<string, LocaleEntry>;
export type Locale = keyof typeof locales;
diff --git a/src/lib/i18n/server.ts b/src/lib/i18n/server.ts
index 3d7e591..0e24695 100644
--- a/src/lib/i18n/server.ts
+++ b/src/lib/i18n/server.ts
@@ -1,13 +1,26 @@
import { cookies } from "next/headers";
+import { getEnv } from "@/lib/cloudflare";
import { LOCALE_COOKIE, createTranslator, loadMessages, resolveLocale } from "./utils";
+import type { Locale, Messages } from "./types";
/** The locale chosen in the preference cookie, for server code that must render in it. */
export async function getRequestLocale() {
return resolveLocale((await cookies()).get(LOCALE_COOKIE)?.value);
}
+/** Server-side catalog load through the static assets binding; English when the catalog cannot be read. */
+export async function loadServerMessages(locale: Locale): Promise<Partial<Messages> | undefined> {
+ try {
+ const assets = getEnv().ASSETS;
+ return await loadMessages(locale, (path) => assets.fetch(new URL(path, "https://mailflare.local")));
+ } catch (error) {
+ console.warn(`Falling back to English: ${error instanceof Error ? error.message : error}`);
+ return undefined;
+ }
+}
+
// For server components and route handlers; client components use `useLanguage()`.
export async function getServerTranslator() {
const locale = await getRequestLocale();
- return createTranslator(locale, await loadMessages(locale));
+ return createTranslator(locale, await loadServerMessages(locale));
}
diff --git a/src/lib/i18n/utils.ts b/src/lib/i18n/utils.ts
index 07cd587..92eedae 100644
--- a/src/lib/i18n/utils.ts
+++ b/src/lib/i18n/utils.ts
@@ -14,9 +14,15 @@ export function getDirection(locale: Locale): "ltr" | "rtl" {
return (locales[locale] as { dir?: "rtl" }).dir ?? "ltr";
}
-/** Fetches the catalog for a locale; English is already bundled, others load on demand. */
-export async function loadMessages(locale: Locale): Promise<Partial<Messages>> {
- return locales[locale].load();
+/** Reads a static asset by path. The browser uses `fetch`; server code passes the `ASSETS` binding. */
+export type AssetReader = (path: string) => Promise<Response>;
+
+/** Fetches the catalog for a locale; English is already bundled, others load on demand from `public/locales`. */
+export async function loadMessages(locale: Locale, read: AssetReader = (path) => fetch(path)): Promise<Partial<Messages>> {
+ if (locale === DEFAULT_LOCALE) return en;
+ const response = await read(`/locales/${locale}.json`);
+ if (!response.ok) throw new Error(`Catalog for ${locale} is unavailable (${response.status})`);
+ return response.json();
}
export type TranslationVars = Record<string, string | number | null | undefined>;