Skip to content

Email for professionals and teams

Translate shortcuts and command palette

Hieu Nguyen (Jack)875d557663a2
diff --git a/src/components/mail-search/mail-search-input.tsx b/src/components/mail-search/mail-search-input.tsx
index c03e5b9..d50b540 100644
--- a/src/components/mail-search/mail-search-input.tsx
+++ b/src/components/mail-search/mail-search-input.tsx
@@ -35,6 +35,7 @@ export function MailSearchInput() {
<Search className="h-5 w-5 shrink-0" />
<Input
ref={inputRef}
+ data-mail-search-input=""
onBlur={() => setExpanded(false)}
value={query}
onChange={(event) => setQuery(event.target.value)}
diff --git a/src/components/shortcuts/command-palette.tsx b/src/components/shortcuts/command-palette.tsx
index 138ad6f..670a9f6 100644
--- a/src/components/shortcuts/command-palette.tsx
+++ b/src/components/shortcuts/command-palette.tsx
@@ -2,7 +2,9 @@
import React, { useState, useEffect, useRef, useMemo } from "react";
import { Search, CornerDownLeft } from "lucide-react";
+import { useLanguage } from "@/components/language-provider";
import type { CommandItem } from "./types";
+import type { TranslationKey } from "@/lib/i18n/types";
import { filterCommands, groupCommandsByCategory } from "./command-palette-utils";
import { CommandPaletteItem } from "./command-palette-item";
@@ -19,6 +21,7 @@ function CommandPaletteDialog({
onClose: () => void;
commands: CommandItem[];
}) {
+ const { t } = useLanguage();
const [query, setQuery] = useState("");
const [selectedIndex, setSelectedIndex] = useState(0);
const inputRef = useRef<HTMLInputElement>(null);
@@ -83,7 +86,7 @@ function CommandPaletteDialog({
setQuery(e.target.value);
setSelectedIndex(0);
}}
- placeholder="Type a command or search actions..."
+ placeholder={t("palette.placeholder")}
className="w-full bg-transparent text-neutral-900 placeholder-neutral-400 text-[15px] focus:outline-none"
/>
<kbd className="px-2 py-0.5 text-xs font-semibold text-neutral-400 bg-neutral-100 border border-neutral-200 rounded-md shadow-2xs">
@@ -95,13 +98,13 @@ function CommandPaletteDialog({
<div className="max-h-80 overflow-y-auto p-2">
{filteredCommands.length === 0 ? (
<div className="p-8 text-center text-sm text-neutral-400">
- No matching commands found for &ldquo;{query}&rdquo;
+ {t("palette.noMatch", { query })}
</div>
) : (
Object.entries(grouped).map(([category, items]) => (
<div key={category} className="mb-2 last:mb-0">
<div className="px-3 py-1 text-[11px] font-semibold uppercase tracking-wider text-neutral-400">
- {category}
+ {t(`shortcut.category.${category}` as TranslationKey)}
</div>
{items.map((item) => {
const isCurrent = flatIndex === activeIndex;
@@ -133,14 +136,14 @@ function CommandPaletteDialog({
<kbd className="px-1.5 py-0.5 bg-neutral-200 rounded mr-1 text-[10px]">
↑↓
</kbd>
- to navigate
+ {t("palette.navigate")}
</span>
<span className="flex items-center">
<CornerDownLeft className="w-3 h-3 mr-1 inline" />
- to select
+ {t("palette.select")}
</span>
</div>
- <span className="text-[11px]">Mailflare Actions</span>
+ <span className="text-[11px]">{t("palette.actions")}</span>
</div>
</div>
</div>
diff --git a/src/components/shortcuts/shortcuts-context.tsx b/src/components/shortcuts/shortcuts-context.tsx
index 34fa570..61d918e 100644
--- a/src/components/shortcuts/shortcuts-context.tsx
+++ b/src/components/shortcuts/shortcuts-context.tsx
@@ -15,6 +15,7 @@ import {
Settings,
HelpCircle,
} from "lucide-react";
+import { useLanguage } from "@/components/language-provider";
import { useCompose } from "@/components/compose/compose-context";
import type { ShortcutDefinition, CommandItem } from "./types";
import { useHotkeys } from "./use-hotkeys";
@@ -56,6 +57,7 @@ export function ShortcutsProvider({
extraShortcuts?: ShortcutDefinition[];
extraCommands?: CommandItem[];
}) {
+ const { t } = useLanguage();
const router = useRouter();
const { openComposer } = useCompose();
const {
@@ -109,29 +111,29 @@ export function ShortcutsProvider({
{
key: "k",
modifiers: ["meta", "ctrl"],
- label: "Command Palette",
+ label: t("shortcut.commandPalette"),
category: "General",
action: () => setIsCommandPaletteOpen((prev) => !prev),
},
{
key: "?",
- label: "Shortcuts Cheat Sheet",
+ label: t("shortcut.cheatSheet"),
category: "General",
action: () => setIsHelpModalOpen((prev) => !prev),
},
{
key: "c",
- label: "Compose Email",
+ label: t("shortcut.compose"),
category: "Composing",
action: () => openComposer(),
},
{
key: "/",
- label: "Search Mail",
+ label: t("shortcut.searchMail"),
category: "Navigation",
action: () => {
const searchInput = document.querySelector<HTMLInputElement>(
- 'input[placeholder*="Search"]'
+ 'input[data-mail-search-input]'
);
if (searchInput) {
searchInput.focus();
@@ -141,55 +143,55 @@ export function ShortcutsProvider({
},
{
key: "g i",
- label: "Go to Inbox",
+ label: t("shortcut.goInbox"),
category: "Navigation",
action: () => router.push("/inbox"),
},
{
key: "g s",
- label: "Go to Starred",
+ label: t("shortcut.goStarred"),
category: "Navigation",
action: () => router.push("/starred"),
},
{
key: "g z",
- label: "Go to Snoozed",
+ label: t("shortcut.goSnoozed"),
category: "Navigation",
action: () => router.push("/snoozed"),
},
{
key: "g t",
- label: "Go to Sent",
+ label: t("shortcut.goSent"),
category: "Navigation",
action: () => router.push("/sent"),
},
{
key: "g d",
- label: "Go to Drafts",
+ label: t("shortcut.goDrafts"),
category: "Navigation",
action: () => router.push("/drafts"),
},
{
key: "g a",
- label: "Go to Archived",
+ label: t("shortcut.goArchived"),
category: "Navigation",
action: () => router.push("/archived"),
},
{
key: "g !",
- label: "Go to Spam",
+ label: t("shortcut.goSpam"),
category: "Navigation",
action: () => router.push("/spam"),
},
{
key: "g x",
- label: "Go to Trash",
+ label: t("shortcut.goTrash"),
category: "Navigation",
action: () => router.push("/trash"),
},
{
key: "escape",
- label: "Dismiss Modal / Clear Focus",
+ label: t("shortcut.dismiss"),
category: "General",
action: () => {
setIsCommandPaletteOpen(false);
@@ -198,7 +200,7 @@ export function ShortcutsProvider({
},
...customShortcuts,
];
- }, [router, openComposer, customShortcuts]);
+ }, [router, openComposer, customShortcuts, t]);
useHotkeys(baseShortcuts, { enabled: shortcutsEnabled && !shortcutsPreferenceLoading });
@@ -207,8 +209,8 @@ export function ShortcutsProvider({
const builtins: CommandItem[] = [
{
id: "compose",
- title: "Compose new message",
- subtitle: "Open draft editor",
+ title: t("palette.composeTitle"),
+ subtitle: t("palette.composeSubtitle"),
category: "Actions",
icon: MailPlus,
shortcut: "c",
@@ -216,7 +218,7 @@ export function ShortcutsProvider({
},
{
id: "nav-inbox",
- title: "Go to Inbox",
+ title: t("shortcut.goInbox"),
category: "Navigation",
icon: Inbox,
shortcut: "g i",
@@ -224,7 +226,7 @@ export function ShortcutsProvider({
},
{
id: "nav-starred",
- title: "Go to Starred",
+ title: t("shortcut.goStarred"),
category: "Navigation",
icon: Star,
shortcut: "g s",
@@ -232,7 +234,7 @@ export function ShortcutsProvider({
},
{
id: "nav-snoozed",
- title: "Go to Snoozed",
+ title: t("shortcut.goSnoozed"),
category: "Navigation",
icon: Clock,
shortcut: "g z",
@@ -240,7 +242,7 @@ export function ShortcutsProvider({
},
{
id: "nav-sent",
- title: "Go to Sent",
+ title: t("shortcut.goSent"),
category: "Navigation",
icon: Send,
shortcut: "g t",
@@ -248,7 +250,7 @@ export function ShortcutsProvider({
},
{
id: "nav-drafts",
- title: "Go to Drafts",
+ title: t("shortcut.goDrafts"),
category: "Navigation",
icon: FileText,
shortcut: "g d",
@@ -256,7 +258,7 @@ export function ShortcutsProvider({
},
{
id: "nav-archived",
- title: "Go to Archived",
+ title: t("shortcut.goArchived"),
category: "Navigation",
icon: Archive,
shortcut: "g a",
@@ -264,7 +266,7 @@ export function ShortcutsProvider({
},
{
id: "nav-spam",
- title: "Go to Spam",
+ title: t("shortcut.goSpam"),
category: "Navigation",
icon: ShieldAlert,
shortcut: "g !",
@@ -272,7 +274,7 @@ export function ShortcutsProvider({
},
{
id: "nav-trash",
- title: "Go to Trash",
+ title: t("shortcut.goTrash"),
category: "Navigation",
icon: Trash2,
shortcut: "g x",
@@ -280,16 +282,16 @@ export function ShortcutsProvider({
},
{
id: "settings-account",
- title: "Account Settings",
- subtitle: "Profile, password & preferences",
+ title: t("palette.accountTitle"),
+ subtitle: t("palette.accountSubtitle"),
category: "Settings",
icon: Settings,
perform: () => router.push("/settings/account"),
},
{
id: "show-help",
- title: "Keyboard Shortcuts Cheat Sheet",
- subtitle: "View all quick keys",
+ title: t("palette.helpTitle"),
+ subtitle: t("palette.helpSubtitle"),
category: "General",
icon: HelpCircle,
shortcut: "?",
@@ -298,7 +300,7 @@ export function ShortcutsProvider({
];
return [...builtins, ...customCommands];
- }, [router, openComposer, customCommands]);
+ }, [router, openComposer, customCommands, t]);
return (
<ShortcutsContext.Provider
diff --git a/src/components/shortcuts/shortcuts-help-dialog.tsx b/src/components/shortcuts/shortcuts-help-dialog.tsx
index cbb9f5c..1dff357 100644
--- a/src/components/shortcuts/shortcuts-help-dialog.tsx
+++ b/src/components/shortcuts/shortcuts-help-dialog.tsx
@@ -2,6 +2,8 @@
import React from "react";
import { X, Keyboard } from "lucide-react";
+import { useLanguage } from "@/components/language-provider";
+import type { TranslationKey } from "@/lib/i18n/types";
import type { ShortcutDefinition } from "./types";
interface ShortcutsHelpDialogProps {
@@ -15,6 +17,7 @@ export function ShortcutsHelpDialog({
onClose,
shortcuts,
}: ShortcutsHelpDialogProps) {
+ const { t } = useLanguage();
if (!isOpen) return null;
const grouped = shortcuts.reduce((acc, item) => {
@@ -27,7 +30,7 @@ export function ShortcutsHelpDialog({
const parts: string[] = [];
if (shortcut.modifiers) {
shortcut.modifiers.forEach((m) => {
- if (m === "ctrl") parts.push("Ctrl");
+ if (m === "ctrl") parts.push(t("shortcutsHelp.ctrl"));
if (m === "meta") parts.push("⌘");
if (m === "alt") parts.push("Alt");
if (m === "shift") parts.push("Shift");
@@ -53,16 +56,17 @@ export function ShortcutsHelpDialog({
</div>
<div>
<h2 className="text-base font-semibold text-neutral-900">
- Keyboard Shortcuts
+ {t("shortcutsHelp.title")}
</h2>
<p className="text-xs text-neutral-400">
- Superhuman &amp; Gmail style quick keys
+ {t("shortcutsHelp.subtitle")}
</p>
</div>
</div>
<button
type="button"
onClick={onClose}
+ aria-label={t("shortcutsHelp.close")}
className="text-neutral-400 hover:text-neutral-700 p-1.5 rounded-lg hover:bg-neutral-100 transition-colors"
>
<X className="w-5 h-5" />
@@ -74,7 +78,7 @@ export function ShortcutsHelpDialog({
{Object.entries(grouped).map(([category, items]) => (
<div key={category} className="space-y-3">
<h3 className="text-xs font-semibold uppercase tracking-wider text-neutral-400 border-b border-neutral-100 pb-1.5">
- {category}
+ {t(`shortcut.category.${category}` as TranslationKey)}
</h3>
<div className="space-y-2">
{items.map((item, idx) => (
@@ -98,18 +102,10 @@ export function ShortcutsHelpDialog({
{/* Footer */}
<div className="px-6 py-3 bg-neutral-50 border-t border-neutral-100 flex items-center justify-between text-xs text-neutral-400">
<span>
- Press{" "}
- <kbd className="px-1.5 py-0.5 bg-neutral-200 text-neutral-700 rounded font-mono">
- ?
- </kbd>{" "}
- to toggle
+ {t("shortcutsHelp.pressToToggle", { key: "?" })}
</span>
<span>
- Press{" "}
- <kbd className="px-1.5 py-0.5 bg-neutral-200 text-neutral-700 rounded font-mono">
- ESC
- </kbd>{" "}
- to close
+ {t("shortcutsHelp.pressToClose", { key: "ESC" })}
</span>
</div>
</div>
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index ec5b976..aa76641 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -336,5 +336,42 @@
"accountSettings.details": "Details",
"accountSettings.password": "Password",
"accountSettings.permissions": "Permissions",
- "accountSettings.mailboxes": "Mailboxes"
+ "accountSettings.mailboxes": "Mailboxes",
+ "shortcut.commandPalette": "Command Palette",
+ "shortcut.cheatSheet": "Shortcuts Cheat Sheet",
+ "shortcut.compose": "Compose Email",
+ "shortcut.searchMail": "Search Mail",
+ "shortcut.goInbox": "Go to Inbox",
+ "shortcut.goStarred": "Go to Starred",
+ "shortcut.goSnoozed": "Go to Snoozed",
+ "shortcut.goSent": "Go to Sent",
+ "shortcut.goDrafts": "Go to Drafts",
+ "shortcut.goArchived": "Go to Archived",
+ "shortcut.goSpam": "Go to Spam",
+ "shortcut.goTrash": "Go to Trash",
+ "shortcut.dismiss": "Dismiss Modal / Clear Focus",
+ "shortcut.category.Navigation": "Navigation",
+ "shortcut.category.Actions": "Actions",
+ "shortcut.category.Composing": "Composing",
+ "shortcut.category.Selection": "Selection",
+ "shortcut.category.General": "General",
+ "shortcut.category.Settings": "Settings",
+ "shortcut.category.Mailboxes": "Mailboxes",
+ "palette.composeTitle": "Compose new message",
+ "palette.composeSubtitle": "Open draft editor",
+ "palette.accountTitle": "Account Settings",
+ "palette.accountSubtitle": "Profile, password & preferences",
+ "palette.helpTitle": "Keyboard Shortcuts Cheat Sheet",
+ "palette.helpSubtitle": "View all quick keys",
+ "palette.placeholder": "Type a command or search actions...",
+ "palette.noMatch": "No matching commands found for “{query}”",
+ "palette.navigate": "to navigate",
+ "palette.select": "to select",
+ "palette.actions": "Mailflare Actions",
+ "shortcutsHelp.title": "Keyboard Shortcuts",
+ "shortcutsHelp.subtitle": "Superhuman & Gmail style quick keys",
+ "shortcutsHelp.close": "Close",
+ "shortcutsHelp.pressToToggle": "Press {key} to toggle",
+ "shortcutsHelp.pressToClose": "Press {key} to close",
+ "shortcutsHelp.ctrl": "Ctrl"
}
diff --git a/src/lib/i18n/pt-BR.json b/src/lib/i18n/pt-BR.json
index bccc803..cb52eac 100644
--- a/src/lib/i18n/pt-BR.json
+++ b/src/lib/i18n/pt-BR.json
@@ -336,5 +336,42 @@
"accountSettings.details": "Detalhes",
"accountSettings.password": "Senha",
"accountSettings.permissions": "Permissões",
- "accountSettings.mailboxes": "Caixas de correio"
+ "accountSettings.mailboxes": "Caixas de correio",
+ "shortcut.commandPalette": "Paleta de comandos",
+ "shortcut.cheatSheet": "Guia de atalhos",
+ "shortcut.compose": "Escrever e-mail",
+ "shortcut.searchMail": "Pesquisar e-mails",
+ "shortcut.goInbox": "Ir para a caixa de entrada",
+ "shortcut.goStarred": "Ir para Com estrela",
+ "shortcut.goSnoozed": "Ir para Adiados",
+ "shortcut.goSent": "Ir para Enviados",
+ "shortcut.goDrafts": "Ir para Rascunhos",
+ "shortcut.goArchived": "Ir para Arquivados",
+ "shortcut.goSpam": "Ir para Spam",
+ "shortcut.goTrash": "Ir para a Lixeira",
+ "shortcut.dismiss": "Fechar janela / Limpar foco",
+ "shortcut.category.Navigation": "Navegação",
+ "shortcut.category.Actions": "Ações",
+ "shortcut.category.Composing": "Escrita",
+ "shortcut.category.Selection": "Seleção",
+ "shortcut.category.General": "Geral",
+ "shortcut.category.Settings": "Configurações",
+ "shortcut.category.Mailboxes": "Caixas de correio",
+ "palette.composeTitle": "Escrever nova mensagem",
+ "palette.composeSubtitle": "Abrir editor de rascunho",
+ "palette.accountTitle": "Configurações da conta",
+ "palette.accountSubtitle": "Perfil, senha e preferências",
+ "palette.helpTitle": "Guia de atalhos do teclado",
+ "palette.helpSubtitle": "Ver todos os atalhos",
+ "palette.placeholder": "Digite um comando ou pesquise ações...",
+ "palette.noMatch": "Nenhum comando encontrado para “{query}”",
+ "palette.navigate": "para navegar",
+ "palette.select": "para selecionar",
+ "palette.actions": "Ações do Mailflare",
+ "shortcutsHelp.title": "Atalhos de teclado",
+ "shortcutsHelp.subtitle": "Atalhos no estilo Superhuman e Gmail",
+ "shortcutsHelp.close": "Fechar",
+ "shortcutsHelp.pressToToggle": "Pressione {key} para alternar",
+ "shortcutsHelp.pressToClose": "Pressione {key} para fechar",
+ "shortcutsHelp.ctrl": "Ctrl"
}