diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2fac967..062d338 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -149,6 +149,7 @@ jobs: - run: npm run test:polling - run: npm run test:replay - run: npm run test:upload + - run: npm run test:i18n - run: npm run build:static python: diff --git a/web/package.json b/web/package.json index 4c823af..f5265be 100644 --- a/web/package.json +++ b/web/package.json @@ -15,7 +15,8 @@ "generate:presets": "ts-node -P tsconfig.scripts.json src/scripts/generate-theme-presets.ts", "test:polling": "node --test scripts/polling.test.mjs", "test:replay": "node --test scripts/replay.test.mjs", - "test:upload": "node --test scripts/upload.test.mjs" + "test:upload": "node --test scripts/upload.test.mjs", + "test:i18n": "node scripts/check-i18n.mjs" }, "lint-staged": { "*.{js,ts,jsx,tsx}": [ diff --git a/web/scripts/check-i18n.mjs b/web/scripts/check-i18n.mjs new file mode 100644 index 0000000..149308b --- /dev/null +++ b/web/scripts/check-i18n.mjs @@ -0,0 +1,64 @@ +import { readFileSync, readdirSync, statSync } from "node:fs"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; + +// Every literal t("...") / t('...') key must exist in the locale dictionary +// with the same {placeholders}. Dynamic keys (variables, template literals +// with ${}) are skipped: there is nothing to compare them against. +const root = join(dirname(fileURLToPath(import.meta.url)), ".."); +const dict = JSON.parse(readFileSync(join(root, "src/i18n/locales/tr.json"), "utf8")); + +const files = []; +function walk(dir) { + for (const name of readdirSync(dir)) { + const p = join(dir, name); + const st = statSync(p); + if (st.isDirectory()) walk(p); + else if (/\.(ts|tsx)$/.test(name)) files.push(p); + } +} +walk(join(root, "src")); + +const calls = new Map(); // key -> first file that uses it +const literalCall = /(?:^|[^\w$.])t\(\s*(?:"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)')/gm; +for (const file of files) { + const src = readFileSync(file, "utf8"); + for (const m of src.matchAll(literalCall)) { + const key = + m[1] !== undefined ? JSON.parse(`"${m[1]}"`) : m[2].replace(/\\(['\\])/g, "$1"); + if (!calls.has(key)) calls.set(key, file.slice(root.length + 1)); + } +} + +function placeholders(s) { + return [...s.matchAll(/\{(\w+)\}/g)] + .map((m) => m[1]) + .sort() + .join(","); +} + +const missing = []; +const mismatch = []; +for (const [key, file] of calls) { + if (!Object.prototype.hasOwnProperty.call(dict, key)) { + missing.push(`${file}: ${JSON.stringify(key)}`); + continue; + } + if (placeholders(dict[key]) !== placeholders(key)) { + mismatch.push(`${JSON.stringify(key)}: source {${placeholders(key)}} dict {${placeholders(dict[key])}}`); + } +} + +if (missing.length || mismatch.length) { + if (missing.length) { + console.error(`Missing tr.json entries (${missing.length}):\n${missing.join("\n")}`); + } + if (mismatch.length) { + console.error(`Placeholder mismatches (${mismatch.length}):\n${mismatch.join("\n")}`); + } + process.exit(1); +} + +console.log( + `i18n: ${calls.size} literal keys checked against ${Object.keys(dict).length} tr.json entries`, +); diff --git a/web/scripts/upload.test.mjs b/web/scripts/upload.test.mjs index 733184e..8826bca 100644 --- a/web/scripts/upload.test.mjs +++ b/web/scripts/upload.test.mjs @@ -21,6 +21,9 @@ function setup(mock = false) { require(name) { if (name === "@/lib/mock/enabled") return { MOCK: mock }; if (name === "@/lib/mock/handler") return { mockHandle: () => assert.fail("unexpected mock request") }; + // English passthrough: assertions below match the source (English) messages. + if (name === "@/i18n") + return { t: (key, vars) => key.replace(/\{(\w+)\}/g, (m, k) => (vars && k in vars ? String(vars[k]) : m)) }; throw new Error("Unexpected import: " + name); }, FormData: class { diff --git a/web/src/app/(auth)/login/page.tsx b/web/src/app/(auth)/login/page.tsx index 1ec20b3..9d8d4c1 100644 --- a/web/src/app/(auth)/login/page.tsx +++ b/web/src/app/(auth)/login/page.tsx @@ -11,6 +11,7 @@ import { Checkbox } from "@/components/ui/checkbox"; import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; +import { t } from "@/i18n"; import { api } from "@/lib/api"; import { auth } from "@/lib/auth"; @@ -55,14 +56,14 @@ export default function LoginPage() { .then(({ initialized }) => { if (!initialized) router.replace("/setup"); }) - .catch(() => setError("Unable to connect to the backend service")) + .catch(() => setError(t("Unable to connect to the backend service"))) .finally(() => setChecking(false)); }, [router]); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); if (!agreed) { - setError("Please read and agree to the Terms of Use first"); + setError(t("Please read and agree to the Terms of Use first")); return; } setLoading(true); @@ -72,7 +73,7 @@ export default function LoginPage() { auth.setToken(token); window.location.replace("/function/tasks"); } catch { - setError("Incorrect username or password"); + setError(t("Incorrect username or password")); } finally { setLoading(false); } @@ -80,12 +81,16 @@ export default function LoginPage() { if (checking) { return ( -
- Checking login state… + // Prerendered in the build-time locale; the reader's locale may differ for this brief state. +
+ {t("Checking login state…")}
); } + // Keep the agreement sentence whole: the link text is placed through a placeholder so the word order can follow the locale. + const [agreeBefore, agreeAfter = ""] = t("I have read and agree to {terms}").split("{terms}"); + return (
{/* Left panel */} @@ -103,22 +108,24 @@ export default function LoginPage() {
-

Sign in

-

Welcome back — enter your password to continue using ARTEX

+

{t("Sign in")}

+

+ {t("Welcome back — enter your password to continue using ARTEX")} +

- +
- + setPassword(e.target.value)} - placeholder="Enter your password" + placeholder={t("Enter your password")} autoFocus autoComplete="current-password" /> @@ -131,19 +138,20 @@ export default function LoginPage() { className="mt-0.5" />
{error &&

{error}

}
@@ -156,9 +164,9 @@ export default function LoginPage() {
- ARTEX Terms of Use and Disclaimer + {t("ARTEX Terms of Use and Disclaimer")}

- Version v1.1 · Effective 2026-10-11 · Please read all the following terms in full before signing in + {t("Version v1.1 · Effective 2026-10-11 · Please read all the following terms in full before signing in")}

@@ -169,11 +177,14 @@ export default function LoginPage() { className="max-h-[60vh] space-y-5 overflow-y-auto px-6 py-5 text-sm leading-relaxed text-muted-foreground" >

- This Terms of Use and Disclaimer (the "Statement") is the agreement between you and the ARTEX - project authors and contributors regarding your use of this software. Please read it carefully and fully understand each provision before use, especially the disclaimer, liability-limitation, and prohibition clauses highlighted in bold or color blocks. + {t( + 'This Terms of Use and Disclaimer (the "Statement") is the agreement between you and the ARTEX project authors and contributors regarding your use of this software. Please read it carefully and fully understand each provision before use, especially the disclaimer, liability-limitation, and prohibition clauses highlighted in bold or color blocks.', + )} {" "} - Once you download, install, access, or use this software in any way, you are deemed to have read, understood, and agreed to be bound by all of this Statement. + {t( + "Once you download, install, access, or use this software in any way, you are deemed to have read, understood, and agreed to be bound by all of this Statement.", + )}

@@ -182,12 +193,12 @@ export default function LoginPage() { 1 - Article 1 · Definitions and Open-Source License + {t("Article 1 · Definitions and Open-Source License")}

- This software (ARTEX) is an open-source program released under the GNU Affero General Public License - v3.0 (AGPL-3.0). You may freely use, copy, modify, and distribute it under that license; however, any derivative work (including online services provided to third parties over a network) must likewise be open-sourced under - the AGPL-3.0 license with the complete corresponding source code made public to its users. The full AGPL-3.0 terms are governed by the accompanying LICENSE file. + {t( + "This software (ARTEX) is an open-source program released under the GNU Affero General Public License v3.0 (AGPL-3.0). You may freely use, copy, modify, and distribute it under that license; however, any derivative work (including online services provided to third parties over a network) must likewise be open-sourced under the AGPL-3.0 license with the complete corresponding source code made public to its users. The full AGPL-3.0 terms are governed by the accompanying LICENSE file.", + )}

@@ -196,10 +207,12 @@ export default function LoginPage() { 2 - Article 2 · Permitted Scope of Use + {t("Article 2 · Permitted Scope of Use")}

- This software is a security-testing platform. You may use it for: personal study, code research, and technical verification in environments you set up yourself; security testing of systems you own; security testing of third-party systems when you hold the owner's explicit authorization; and testing within the written scope of a bug bounty or vulnerability disclosure program, in compliance with that program's rules of engagement. You are responsible for obtaining and keeping proof of authorization, for staying inside the authorized scope, and for the safety and proportionality of every action the software takes on your behalf. + {t( + "This software is a security-testing platform. You may use it for: personal study, code research, and technical verification in environments you set up yourself; security testing of systems you own; security testing of third-party systems when you hold the owner's explicit authorization; and testing within the written scope of a bug bounty or vulnerability disclosure program, in compliance with that program's rules of engagement. You are responsible for obtaining and keeping proof of authorization, for staying inside the authorized scope, and for the safety and proportionality of every action the software takes on your behalf.", + )}

@@ -209,15 +222,29 @@ export default function LoginPage() { 3 - Article 3 · Prohibited Conduct + {t("Article 3 · Prohibited Conduct")}
  • - Strictly forbidden: scanning, probing, exploiting, or attacking any system whose owner has not explicitly authorized you to test it, or exceeding the authorized scope or a program's rules of engagement once granted; + {t( + "Strictly forbidden: scanning, probing, exploiting, or attacking any system whose owner has not explicitly authorized you to test it, or exceeding the authorized scope or a program's rules of engagement once granted;", + )} +
  • +
  • + {t( + "Strictly forbidden: using this software for illegal intrusion, data theft, extortion, denial of service (DoS/DDoS), or any destructive or criminal activity;", + )} +
  • +
  • + {t( + "Strictly forbidden: removing, tampering with, or circumventing any copyright, license, or security notice in this software or its output;", + )} +
  • +
  • + {t( + "Strictly forbidden: engaging in any conduct that violates the laws, regulations, or regulatory rules of your country or region.", + )}
  • -
  • Strictly forbidden: using this software for illegal intrusion, data theft, extortion, denial of service (DoS/DDoS), or any destructive or criminal activity;
  • -
  • Strictly forbidden: removing, tampering with, or circumventing any copyright, license, or security notice in this software or its output;
  • -
  • Strictly forbidden: engaging in any conduct that violates the laws, regulations, or regulatory rules of your country or region.
@@ -226,11 +253,12 @@ export default function LoginPage() { 4 - Article 4 · Intellectual Property + {t("Article 4 · Intellectual Property")}

- The copyright and related intellectual property of this software belong to the project authors and contributors, who grant - you the corresponding rights within the scope of the AGPL-3.0 license. Beyond the rights expressly granted by that license, this Statement grants you no other rights, expressly or by implication. + {t( + "The copyright and related intellectual property of this software belong to the project authors and contributors, who grant you the corresponding rights within the scope of the AGPL-3.0 license. Beyond the rights expressly granted by that license, this Statement grants you no other rights, expressly or by implication.", + )}

@@ -239,10 +267,12 @@ export default function LoginPage() { 5 - Article 5 · Data and Privacy + {t("Article 5 · Data and Privacy")}

- This software is a self-deployable open-source program; the authors run no centralized service and neither collect nor upload your usage data. All data you generate, process, or touch while using it stays under your control, and you are responsible for its legality and security; any consequence of improper data handling is yours to bear. + {t( + "This software is a self-deployable open-source program; the authors run no centralized service and neither collect nor upload your usage data. All data you generate, process, or touch while using it stays under your control, and you are responsible for its legality and security; any consequence of improper data handling is yours to bear.", + )}

@@ -251,13 +281,17 @@ export default function LoginPage() { 6 - Article 6 · Compliance and Legal Liability + {t("Article 6 · Compliance and Legal Liability")}

- You must comply on your own with all laws and regulations of your country or region on cybersecurity, data security and personal-information protection, computer crime, and the like (for example, laws on unauthorized access to computer systems, on personal-data protection, and on the responsibilities of security researchers and penetration testers in your jurisdiction). + {t( + "You must comply on your own with all laws and regulations of your country or region on cybersecurity, data security and personal-information protection, computer crime, and the like (for example, laws on unauthorized access to computer systems, on personal-data protection, and on the responsibilities of security researchers and penetration testers in your jurisdiction).", + )} {" "} - All legal liability and consequences arising from your violation of the above laws and regulations or of this Statement are borne by you alone and have nothing to do with this software's authors and contributors. + {t( + "All legal liability and consequences arising from your violation of the above laws and regulations or of this Statement are borne by you alone and have nothing to do with this software's authors and contributors.", + )}

@@ -267,11 +301,12 @@ export default function LoginPage() { 7 - Article 7 · Disclaimer and Limitation of Liability + {t("Article 7 · Disclaimer and Limitation of Liability")}

- This software is provided on an "AS IS" and "AS - AVAILABLE" basis, without any express or implied warranty, including but not limited to warranties of merchantability, fitness for a particular purpose, accuracy, and non-infringement. To the maximum extent permitted by applicable law, this software's authors and contributors are not liable for any direct, indirect, incidental, special, or consequential loss arising from using or being unable to use this software (regardless of whether it is used properly), including but not limited to data loss, system damage, business interruption, loss of profit, or legal disputes. + {t( + 'This software is provided on an "AS IS" and "AS AVAILABLE" basis, without any express or implied warranty, including but not limited to warranties of merchantability, fitness for a particular purpose, accuracy, and non-infringement. To the maximum extent permitted by applicable law, this software\'s authors and contributors are not liable for any direct, indirect, incidental, special, or consequential loss arising from using or being unable to use this software (regardless of whether it is used properly), including but not limited to data loss, system damage, business interruption, loss of profit, or legal disputes.', + )}

@@ -280,17 +315,19 @@ export default function LoginPage() { 8 - Article 8 · Changes to the Terms and Final Interpretation + {t("Article 8 · Changes to the Terms and Final Interpretation")}

- The authors may update this Statement from time to time as laws, regulations, or project development require; the updated version ships with the project and takes effect on its publication date, and your continued use of this software means you accept the revised terms. To the extent permitted by law, the authors hold the final right of interpretation of this Statement. If any provision of this Statement is held invalid, the remaining provisions stay in effect. + {t( + "The authors may update this Statement from time to time as laws, regulations, or project development require; the updated version ships with the project and takes effect on its publication date, and your continued use of this software means you accept the revised terms. To the extent permitted by law, the authors hold the final right of interpretation of this Statement. If any provision of this Statement is held invalid, the remaining provisions stay in effect.", + )}

- {readToEnd ? "You have read all the terms" : "Scroll the terms to the bottom to confirm"} + {readToEnd ? t("You have read all the terms") : t("Scroll the terms to the bottom to confirm")}

diff --git a/web/src/app/(auth)/setup/page.tsx b/web/src/app/(auth)/setup/page.tsx index 0df08a7..152bca3 100644 --- a/web/src/app/(auth)/setup/page.tsx +++ b/web/src/app/(auth)/setup/page.tsx @@ -7,6 +7,7 @@ import { useRouter } from "next/navigation"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; +import { t } from "@/i18n"; import { api } from "@/lib/api"; import { auth } from "@/lib/auth"; @@ -29,7 +30,7 @@ export default function SetupPage() { if (initialized) router.replace("/login"); }) .catch((err) => { - setError(err instanceof Error ? err.message : "Unable to connect to the backend service"); + setError(err instanceof Error ? err.message : t("Unable to connect to the backend service")); setUnavailable(true); }) .finally(() => setChecking(false)); @@ -38,11 +39,11 @@ export default function SetupPage() { async function handleSubmit(e: React.FormEvent) { e.preventDefault(); if (password !== confirm) { - setError("The two passwords do not match"); + setError(t("The two passwords do not match")); return; } if (password.length < 12) { - setError("Password must be at least 12 characters"); + setError(t("Password must be at least 12 characters")); return; } setLoading(true); @@ -52,7 +53,7 @@ export default function SetupPage() { auth.setToken(token); router.replace("/function/tasks"); } catch (err) { - setError(err instanceof Error ? err.message : "Initialization failed"); + setError(err instanceof Error ? err.message : t("Initialization failed")); } finally { setLoading(false); } @@ -77,52 +78,56 @@ export default function SetupPage() {
-

{unavailable ? "Cannot confirm initialization state" : "Set initial password"}

+

{unavailable ? t("Cannot confirm initialization state") : t("Set initial password")}

{unavailable - ? "The backend or database is temporarily unavailable. To avoid overwriting a password already set on this instance, setup is temporarily closed — restore the service and try again." - : "First time using ARTEX? Enter the setup token from the server log, then set a login password for the account (at least 12 characters)"} + ? t( + "The backend or database is temporarily unavailable. To avoid overwriting a password already set on this instance, setup is temporarily closed — restore the service and try again.", + ) + : t( + "First time using ARTEX? Enter the setup token from the server log, then set a login password for the account (at least 12 characters)", + )}

{unavailable ? (
{error &&

{error}

}
) : (
- + setSetupToken(e.target.value)} - placeholder="Printed in the server log at startup" + placeholder={t("Printed in the server log at startup")} autoFocus autoComplete="off" />
- + setPassword(e.target.value)} - placeholder="At least 12 characters" + placeholder={t("At least 12 characters")} autoComplete="new-password" />
- + setConfirm(e.target.value)} - placeholder="Enter the password again" + placeholder={t("Enter the password again")} autoComplete="new-password" />
@@ -132,7 +137,7 @@ export default function SetupPage() { className="w-full" disabled={loading || !setupToken.trim() || !password || !confirm} > - {loading ? "Saving..." : "Set password and sign in"} + {loading ? t("Saving...") : t("Set password and sign in")}
)} diff --git a/web/src/app/(external)/page.tsx b/web/src/app/(external)/page.tsx index bf37db5..5a64de8 100644 --- a/web/src/app/(external)/page.tsx +++ b/web/src/app/(external)/page.tsx @@ -1,6 +1,8 @@ import { redirect } from "next/navigation"; +import { t } from "@/i18n"; + export default function Home() { redirect("/function/tasks"); - return <>Coming Soon; + return <>{t("Coming Soon")}; } diff --git a/web/src/app/(main)/_components/main-content.tsx b/web/src/app/(main)/_components/main-content.tsx index 129f265..05bc8ed 100644 --- a/web/src/app/(main)/_components/main-content.tsx +++ b/web/src/app/(main)/_components/main-content.tsx @@ -9,6 +9,7 @@ import { X } from "lucide-react"; import { Separator } from "@/components/ui/separator"; import { SidebarTrigger } from "@/components/ui/sidebar"; import { useCurrentUser } from "@/hooks/use-current-user"; +import { t } from "@/i18n"; import { api } from "@/lib/api"; import { getLocalStorageValue, setLocalStorageValue } from "@/lib/local-storage.client"; import { cn } from "@/lib/utils"; @@ -57,11 +58,11 @@ export function MainContent({ children }: { children: ReactNode }) { const updateBanner = latest ? (
- ARTEX {latest} is available. See the release notes. + {t("ARTEX {version} is available. See the release notes.", { version: latest })}
{version && ( - Version · {version} + {t("Version · {version}", { version })} )} diff --git a/web/src/app/(main)/_components/sidebar/account-switcher.tsx b/web/src/app/(main)/_components/sidebar/account-switcher.tsx index 54daaf9..3edc039 100644 --- a/web/src/app/(main)/_components/sidebar/account-switcher.tsx +++ b/web/src/app/(main)/_components/sidebar/account-switcher.tsx @@ -12,6 +12,7 @@ import { DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; +import { t } from "@/i18n"; import { auth } from "@/lib/auth"; import { cn, getInitials } from "@/lib/utils"; @@ -64,7 +65,7 @@ export function AccountSwitcher({
{user.name} - {user.role} + {t(user.role)}
setPwOpen(true)}> - Change password + {t("Change password")} - Sign out + {t("Sign out")} diff --git a/web/src/app/(main)/_components/sidebar/change-password-dialog.tsx b/web/src/app/(main)/_components/sidebar/change-password-dialog.tsx index 5233e84..2d0102f 100644 --- a/web/src/app/(main)/_components/sidebar/change-password-dialog.tsx +++ b/web/src/app/(main)/_components/sidebar/change-password-dialog.tsx @@ -15,6 +15,7 @@ import { } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; +import { t } from "@/i18n"; import { api } from "@/lib/api"; export function ChangePasswordDialog({ @@ -41,37 +42,44 @@ export function ChangePasswordDialog({ function submit(e: React.FormEvent) { e.preventDefault(); if (!oldPassword || !newPassword) { - toast.error("Fill in the current password and the new password"); + toast.error(t("Fill in the current password and the new password")); return; } if (newPassword !== confirmPassword) { - toast.error("The two new passwords do not match"); + toast.error(t("The two new passwords do not match")); return; } setSaving(true); api .changePassword(oldPassword, newPassword) .then(() => { - toast.success("Password changed"); + toast.success(t("Password changed")); onOpenChange(false); }) - .catch((err) => toast.error(`Change failed: ${(err as Error).message}`)) + .catch((err) => toast.error(t("Change failed: {error}", { error: (err as Error).message }))) .finally(() => setSaving(false)); } + // The username stays bold; it is placed through a placeholder so the sentence is translated whole. + const [descBefore, descAfter = ""] = t( + "The username is fixed as {username}. Enter the current password to verify; login tokens issued before the change stay valid until they expire.", + ).split("{username}"); + return (
- Change password + {t("Change password")} - The username is fixed as ARTEX. Enter the current password to verify; login tokens issued before the change stay valid until they expire. + {descBefore} + ARTEX + {descAfter}
- +
- +
- + diff --git a/web/src/app/(main)/_components/sidebar/layout-controls.tsx b/web/src/app/(main)/_components/sidebar/layout-controls.tsx index 28091b4..cc3c2f7 100644 --- a/web/src/app/(main)/_components/sidebar/layout-controls.tsx +++ b/web/src/app/(main)/_components/sidebar/layout-controls.tsx @@ -21,6 +21,7 @@ import { persistPreference } from "@/lib/preferences/preferences-storage"; import { THEME_PRESET_OPTIONS, type ThemeMode, type ThemePreset } from "@/lib/preferences/theme"; import { applyThemePreset } from "@/lib/preferences/theme-utils"; import { usePreferencesStore } from "@/stores/preferences/preferences-provider"; +import { type Locale, LOCALES, locale, setLocale, t } from "@/i18n"; export function LayoutControls() { const themeMode = usePreferencesStore((s) => s.themeMode); @@ -106,15 +107,33 @@ export function LayoutControls() {
-

Preferences

-

Customize your dashboard layout preferences.

+

{t("Preferences")}

+

{t("Customize your dashboard layout preferences.")}

- + + v && setLocale(v as Locale)} + > + {LOCALES.map((l) => ( + + {l.label} + + ))} + +
+ +
+ - + @@ -154,7 +173,7 @@ export function LayoutControls() {
- + - - Light + + {t("Light")} - - Dark + + {t("Dark")} - - System + + {t("System")}
- + - - Centered + + {t("Centered")} - - Full Width + + {t("Full Width")}
- + - - Sticky + + {t("Sticky")} - - Scroll + + {t("Scroll")}
- + - - Inset + + {t("Inset")} - - Sidebar + + {t("Sidebar")} - - Floating + + {t("Floating")}
- + - - Icon + + {t("Icon")} - - OffCanvas + + {t("OffCanvas")}
diff --git a/web/src/app/(main)/_components/sidebar/nav-documents.tsx b/web/src/app/(main)/_components/sidebar/nav-documents.tsx index 730aa4f..bf74086 100644 --- a/web/src/app/(main)/_components/sidebar/nav-documents.tsx +++ b/web/src/app/(main)/_components/sidebar/nav-documents.tsx @@ -18,6 +18,7 @@ import { SidebarMenuItem, useSidebar, } from "@/components/ui/sidebar"; +import { t } from "@/i18n"; export function NavDocuments({ items, @@ -32,7 +33,7 @@ export function NavDocuments({ return ( - Documents + {t("Documents")} {items.map((item) => ( @@ -46,7 +47,7 @@ export function NavDocuments({ - More + {t("More")} - Open + {t("Open")} - Share + {t("Share")} - Delete + {t("Delete")} @@ -74,7 +75,7 @@ export function NavDocuments({ - More + {t("More")} diff --git a/web/src/app/(main)/_components/sidebar/nav-main.tsx b/web/src/app/(main)/_components/sidebar/nav-main.tsx index 2b5125d..e99c835 100644 --- a/web/src/app/(main)/_components/sidebar/nav-main.tsx +++ b/web/src/app/(main)/_components/sidebar/nav-main.tsx @@ -29,6 +29,7 @@ import { SidebarMenuSubItem, useSidebar, } from "@/components/ui/sidebar"; +import { t } from "@/i18n"; import { cn } from "@/lib/utils"; import type { NavBadge, @@ -321,7 +322,7 @@ function NavItemBadge({ badge }: { badge?: NavBadge }) { badge === "soon" && "border-muted-foreground text-muted-foreground", )} > - {badge} + {t(badge)} ); } diff --git a/web/src/app/(main)/_components/sidebar/nav-user.tsx b/web/src/app/(main)/_components/sidebar/nav-user.tsx index 56cbc65..840274c 100644 --- a/web/src/app/(main)/_components/sidebar/nav-user.tsx +++ b/web/src/app/(main)/_components/sidebar/nav-user.tsx @@ -14,6 +14,7 @@ import { DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { SidebarMenu, SidebarMenuButton, SidebarMenuItem, useSidebar } from "@/components/ui/sidebar"; +import { t } from "@/i18n"; import { auth } from "@/lib/auth"; import { getInitials } from "@/lib/utils"; @@ -79,12 +80,12 @@ export function NavUser({ setPwOpen(true)}> - Change password + {t("Change password")} - Sign out + {t("Sign out")} diff --git a/web/src/app/(main)/_components/sidebar/search-dialog.tsx b/web/src/app/(main)/_components/sidebar/search-dialog.tsx index d07251d..fd8059a 100644 --- a/web/src/app/(main)/_components/sidebar/search-dialog.tsx +++ b/web/src/app/(main)/_components/sidebar/search-dialog.tsx @@ -17,6 +17,7 @@ import { CommandList, CommandSeparator, } from "@/components/ui/command"; +import { t } from "@/i18n"; import type { NavMainItem } from "@/navigation/sidebar/sidebar-items"; import { sidebarItems } from "@/navigation/sidebar/sidebar-items"; @@ -33,7 +34,7 @@ type SearchItem = { const sidebarGroupLabels = new Set(sidebarItems.flatMap((group) => (group.label ? [group.label] : []))); function getSubItemGroup(groupLabel: string | undefined, itemTitle: string) { - return sidebarGroupLabels.has(itemTitle) ? (groupLabel ?? "Other") : itemTitle; + return sidebarGroupLabels.has(itemTitle) ? (groupLabel ?? t("Other")) : itemTitle; } const searchItems: SearchItem[] = sidebarItems.flatMap((group) => @@ -52,7 +53,7 @@ const searchItems: SearchItem[] = sidebarItems.flatMap((group) => return [ { id: item.id, - group: group.label ?? "Other", + group: group.label ?? t("Other"), label: item.title, url: item.url, icon: item.icon, @@ -138,16 +139,16 @@ export function SearchDialog() { className="px-0! font-normal text-muted-foreground hover:no-underline" > - Search + {t("Search")} ⌘J - + - No results found. + {t("No results found.")} {query ? renderGroups(searchItems) : renderGroups(recommendations)} diff --git a/web/src/app/(main)/_components/sidebar/sidebar-support-card.tsx b/web/src/app/(main)/_components/sidebar/sidebar-support-card.tsx index 5d41598..6b05655 100644 --- a/web/src/app/(main)/_components/sidebar/sidebar-support-card.tsx +++ b/web/src/app/(main)/_components/sidebar/sidebar-support-card.tsx @@ -4,24 +4,27 @@ import { siX } from "simple-icons"; import { SimpleIcon } from "@/components/simple-icon"; import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; +import { t } from "@/i18n"; export function SidebarSupportCard() { + // The X link sits inside the sentence through a placeholder so the word order can follow the locale. + const [before, after = ""] = t("Open an issue or do reach out to me on {x}.").split("{x}"); return ( - Looking for something more? + {t("Looking for something more?")} - Open an issue or do reach out to me on  + {before.trimEnd()}  - . + {after} diff --git a/web/src/app/(main)/_components/sidebar/theme-switcher.tsx b/web/src/app/(main)/_components/sidebar/theme-switcher.tsx index a95a83a..b8217cb 100644 --- a/web/src/app/(main)/_components/sidebar/theme-switcher.tsx +++ b/web/src/app/(main)/_components/sidebar/theme-switcher.tsx @@ -3,11 +3,18 @@ import { Monitor, Moon, Sun } from "lucide-react"; import { Button } from "@/components/ui/button"; +import { t } from "@/i18n"; import { persistPreference } from "@/lib/preferences/preferences-storage"; import { usePreferencesStore } from "@/stores/preferences/preferences-provider"; const THEME_CYCLE = ["light", "dark", "system"] as const; +const THEME_LABELS: Record<(typeof THEME_CYCLE)[number], string> = { + light: t("Light"), + dark: t("Dark"), + system: t("System"), +}; + export function ThemeSwitcher() { const themeMode = usePreferencesStore((s) => s.themeMode); const setThemeMode = usePreferencesStore((s) => s.setThemeMode); @@ -21,7 +28,7 @@ export function ThemeSwitcher() { }; return ( - @@ -234,7 +235,7 @@ function Composer({ variant="ghost" onClick={() => fileInputRef.current?.click()} disabled={disabled || uploading} - title="Upload files" + title={t("Upload files")} > {uploading ? : } @@ -250,14 +251,14 @@ function Composer({ onKeyDown={onKeyDown} /> {running && allowBtw && isBtwCommand(value) && ( - )} {running ? ( // while a run is in flight the send button becomes a stop button — // aborts just this session (the trigger queue keeps going). - ) : ( @@ -265,8 +266,8 @@ function Composer({ size="icon" onClick={onSend} disabled={disabled || (!value.trim() && atts.length === 0)} - title="Send message" - aria-label="Send message" + title={t("Send message")} + aria-label={t("Send message")} > @@ -294,7 +295,11 @@ function LLMProfileRow({ const [open, setOpen] = React.useState(false); const activeDefault = profiles.find((p) => p.is_default); const current = selected != null ? profiles.find((p) => Number(p.id) === selected) : null; - const label = current ? current.name : `Default${activeDefault ? ` (${activeDefault.name})` : ""}`; + const label = current + ? current.name + : activeDefault + ? t("Default ({name})", { name: activeDefault.name }) + : t("Default"); return (
@@ -309,12 +314,12 @@ function LLMProfileRow({ disabled={disabled} className="flex shrink-0 items-center gap-0.5 text-primary text-xs hover:underline disabled:pointer-events-none disabled:opacity-40" > - Change + {t("Change")} -

Select an LLM profile

+

{t("Select an LLM profile")}

{/* default option */} )}
) : ( @@ -1417,7 +1444,7 @@ export default function ChatPage() { disabled={filteredConversations.length === 0} > - Select + {t("Select")}
))} @@ -1430,7 +1457,7 @@ export default function ChatPage() {
{filteredConversations.length === 0 && (

- {agentFilter === null ? "No conversations yet" : "No conversations for this agent"} + {agentFilter === null ? t("No conversations yet") : t("No conversations for this agent")}

)} {pinnedConversations.map((c) => ( @@ -1496,7 +1523,7 @@ export default function ChatPage() { className="mt-1 w-full" onClick={() => setVisibleConversationCount((count) => count + CONVERSATION_LIST_PAGE)} > - Load more + {t("Load more")} )}
@@ -1517,7 +1544,7 @@ export default function ChatPage() { /> ) : sourceRequested ? (
- {convsLoaded ? "The conversation has been deleted" : "Loading the conversation…"} + {convsLoaded ? t("The conversation has been deleted") : t("Loading the conversation…")}
) : ( - Delete {selectedConversationCount} selected conversations? - Conversation messages and execution records will be deleted with them. This action cannot be undone. + + {t("Delete {count} selected conversations?", { count: selectedConversationCount })} + + + {t("Conversation messages and execution records will be deleted with them. This action cannot be undone.")} + - Cancel + {t("Cancel")} {bulkDeleting && } - {bulkDeleting ? "Deleting" : "Confirm delete"} + {bulkDeleting ? t("Deleting") : t("Confirm delete")} diff --git a/web/src/app/(main)/dashboard/page.tsx b/web/src/app/(main)/dashboard/page.tsx index e2dc053..de514cf 100644 --- a/web/src/app/(main)/dashboard/page.tsx +++ b/web/src/app/(main)/dashboard/page.tsx @@ -40,14 +40,15 @@ import type { UsageStats, } from "@/lib/types"; import { cn } from "@/lib/utils"; +import { t } from "@/i18n"; import { setVisibleInterval } from "@/lib/polling"; // ── chart constants ─────────────────────────────────────────────────────────── const dailyTrendConfig = { - input: { label: "Input", color: "hsl(217 91% 60%)" }, - output: { label: "Output", color: "hsl(263 70% 60%)" }, - cacheRead: { label: "Cache read", color: "hsl(160 60% 45%)" }, + input: { label: t("Input"), color: "hsl(217 91% 60%)" }, + output: { label: t("Output"), color: "hsl(263 70% 60%)" }, + cacheRead: { label: t("Cache read"), color: "hsl(160 60% 45%)" }, } satisfies ChartConfig; // ── helpers ────────────────────────────────────────────────────────────────── @@ -56,12 +57,12 @@ function fmtRel(ts?: string | number): string { if (!ts) return "—"; const ms = Date.now() - (typeof ts === "number" ? ts * 1000 : Date.parse(ts as string)); const s = Math.floor(ms / 1000); - if (s < 60) return `${s}s ago`; + if (s < 60) return t("{n}s ago", { n: s }); const m = Math.floor(s / 60); - if (m < 60) return `${m}m ago`; + if (m < 60) return t("{n}m ago", { n: m }); const h = Math.floor(m / 60); - if (h < 24) return `${h}h ago`; - return `${Math.floor(h / 24)}d ago`; + if (h < 24) return t("{n}h ago", { n: h }); + return t("{n}d ago", { n: Math.floor(h / 24) }); } function fmtTokens(n: number): string { @@ -71,12 +72,12 @@ function fmtTokens(n: number): string { } const ASSET_TYPE_LABELS: Record = { - root_domain: "Root domain", + root_domain: t("Root domain"), ip: "IP", - subdomain: "Subdomain", - app: "App", - service: "Service", - endpoint: "Endpoint", + subdomain: t("Subdomain"), + app: t("App"), + service: t("Service"), + endpoint: t("Endpoint"), }; const ASSET_COLORS: Record = { @@ -473,9 +474,9 @@ export default function DashboardPage() { // activity kind label function kindLabel(a: Activity): string { - if (a.kind === "tool_use") return a.tool ?? "tool_use"; - if (a.kind === "tool_result") return "tool_result"; - return a.kind; + if (a.kind === "tool_use") return a.tool ?? t("tool_use"); + if (a.kind === "tool_result") return t("tool_result"); + return t(a.kind); } function workerColor(w: string): string { @@ -497,8 +498,8 @@ export default function DashboardPage() { {/* ── Header ── */}
-

Overview

-

System-wide status · live refresh

+

{t("Overview")}

+

{t("System-wide status · live refresh")}

@@ -508,7 +509,7 @@ export default function DashboardPage() {
- Active tasks + {t("Active tasks")}
{tasksByStatus.running ?? 0} @@ -516,10 +517,16 @@ export default function DashboardPage() {
- {(tasksByStatus.running ?? 0) > 0 && Exploring {tasksByStatus.running}} - {(tasksByStatus.paused ?? 0) > 0 && Paused {tasksByStatus.paused}} - {(tasksByStatus.done ?? 0) > 0 && Completed {tasksByStatus.done}} - {tasks.length === 0 && No tasks} + {(tasksByStatus.running ?? 0) > 0 && ( + {t("Exploring {count}", { count: tasksByStatus.running })} + )} + {(tasksByStatus.paused ?? 0) > 0 && ( + {t("Paused {count}", { count: tasksByStatus.paused })} + )} + {(tasksByStatus.done ?? 0) > 0 && ( + {t("Completed {count}", { count: tasksByStatus.done })} + )} + {tasks.length === 0 && {t("No tasks")}}
@@ -527,15 +534,15 @@ export default function DashboardPage() {
- Confirmed findings + {t("Confirmed findings")}
{findings.length}
- Critical {findingsBySev.critical} - High {findingsBySev.high} - Medium {findingsBySev.medium} - Low {findingsBySev.low} + {t("Critical {count}", { count: findingsBySev.critical })} + {t("High {count}", { count: findingsBySev.high })} + {t("Medium {count}", { count: findingsBySev.medium })} + {t("Low {count}", { count: findingsBySev.low })}
@@ -543,18 +550,18 @@ export default function DashboardPage() {
- Asset nodes + {t("Asset nodes")}
{totalAssets}
- Shared across tasks + {t("Shared across tasks")}
{/* Traffic exchanges */}
- Traffic exchanges + {t("Traffic exchanges")}
{traffic.length}
@@ -562,10 +569,10 @@ export default function DashboardPage() { {settings?.traffic_capture ? ( <> - Recording + {t("Recording")} ) : ( - Capture is off + {t("Capture is off")} )}
@@ -574,15 +581,18 @@ export default function DashboardPage() {
- Token usage + {t("Token usage")}
{fmtTokens(displayedTokens.input + displayedTokens.output) || "—"}
- In {fmtTokens(displayedTokens.input)} (incl. cache {fmtTokens(displayedTokens.cacheRead)}) · Out{" "} - {fmtTokens(displayedTokens.output)} + {t("In {input} (incl. cache {cache}) · Out {output}", { + input: fmtTokens(displayedTokens.input), + cache: fmtTokens(displayedTokens.cacheRead), + output: fmtTokens(displayedTokens.output), + })}
@@ -593,13 +603,13 @@ export default function DashboardPage() {
- LLM token usage + {t("LLM token usage")} {/* Data source toggle: old = activity stats (includes historical tasks), new = the llm_usage metering ledger (more accurate, only covers data since it was enabled) */}
{( [ - { v: "old", label: "Old" }, - { v: "new", label: "New" }, + { v: "old", label: t("Old") }, + { v: "new", label: t("New") }, ] as const ).map(({ v, label }) => ( {llmProfiles.map((p) => { const key = Number(p.id); @@ -667,7 +681,7 @@ export default function DashboardPage() { : "bg-emerald-500/20 text-emerald-400", )} > - Default + {t("Default")} )} @@ -682,11 +696,13 @@ export default function DashboardPage() {
{/* Total */}
-
Total (input+output)
+
{t("Total (input+output)")}
{fmtTokens(displayedTokens.input + displayedTokens.output) || "—"}
-
{displayedTokens.taskCount} tasks
+
+ {t("{count} tasks", { count: displayedTokens.taskCount })} +
{/* Per-type bars */} @@ -696,19 +712,19 @@ export default function DashboardPage() { const total = displayedTokens.input + displayedTokens.output; return [ { - label: "Input (uncached)", + label: t("Input (uncached)"), value: displayedTokens.input - displayedTokens.cacheRead, barColor: dailyTrendConfig.input.color!, text: "text-blue-400", }, { - label: "Cache hits", + label: t("Cache hits"), value: displayedTokens.cacheRead, barColor: dailyTrendConfig.cacheRead.color!, text: "text-emerald-400", }, { - label: "Output", + label: t("Output"), value: displayedTokens.output, barColor: dailyTrendConfig.output.color!, text: "text-violet-400", @@ -740,7 +756,7 @@ export default function DashboardPage() { const hitPct = denominator > 0 ? Math.round((displayedTokens.cacheRead / denominator) * 100) : 0; return (
- Cache hit rate + {t("Cache hit rate")} 50 ? "text-emerald-400" : "text-amber-400")} > @@ -768,11 +784,11 @@ export default function DashboardPage() {
{( [ - { days: 7, label: "7d" }, - { days: 30, label: "30d" }, - { days: 90, label: "3mo" }, - { days: 180, label: "6mo" }, - { days: 365, label: "1y" }, + { days: 7, label: t("7d") }, + { days: 30, label: t("30d") }, + { days: 90, label: t("3mo") }, + { days: 180, label: t("6mo") }, + { days: 365, label: t("1y") }, ] as const ).map(({ days, label }) => (
) : ( @@ -852,17 +868,17 @@ export default function DashboardPage() {
- Activity feed + {t("Activity feed")}
- {activity.filter((a) => a.kind !== "usage").length} events + {t("{count} events", { count: activity.filter((a) => a.kind !== "usage").length })} - View tasks + {t("View tasks")}
@@ -873,7 +889,7 @@ export default function DashboardPage() { if (count === 0) return null; return ( - {kind} {count} + {t(kind)} {count} ); })} @@ -881,7 +897,7 @@ export default function DashboardPage() {
{recentActivity.length === 0 ? ( -
No activity records
+
{t("No activity records")}
) : ( recentActivity.map((a) => (
@@ -899,7 +915,7 @@ export default function DashboardPage() {
- {a.kind} + {t(a.kind)}
{fmtRel(a.ts)}
@@ -914,19 +930,19 @@ export default function DashboardPage() {
- Findings + {t("Findings")}
- All + {t("All")}
{recentFindings.length === 0 ? ( -
No findings
+
{t("No findings")}
) : ( recentFindings.map((f) => (
@@ -959,15 +975,15 @@ export default function DashboardPage() {
- Tasks + {t("Tasks")}
- {tasks.length} tasks + {t("{count} tasks", { count: tasks.length })} - All + {t("All")}
@@ -979,7 +995,7 @@ export default function DashboardPage() { key={h} className="px-4 py-2 text-left text-[9px] font-semibold uppercase tracking-widest text-muted-foreground first:pl-4" > - {h} + {t(h)} ))} @@ -988,7 +1004,7 @@ export default function DashboardPage() { {sortedTasks.length === 0 ? ( - No tasks + {t("No tasks")} ) : ( @@ -1046,12 +1062,12 @@ export default function DashboardPage() {
{/* Asset distribution */} - - Asset distribution + + {t("Asset distribution")} {assetByType.length === 0 ? ( -
No asset data
+
{t("No asset data")}
) : (
{assetByType.map(([type, count]) => ( @@ -1071,18 +1087,20 @@ export default function DashboardPage() {
)} -
{totalAssets} nodes in total
+
+ {t("{count} nodes in total", { count: totalAssets })} +
{/* Traffic status codes */} - - Traffic status codes + + {t("Traffic status codes")} {/* bar chart */} {trafficByCodes.length === 0 ? ( -
No traffic data
+
{t("No traffic data")}
) : ( <>
@@ -1099,7 +1117,7 @@ export default function DashboardPage() {
-
Recent requests
+
{t("Recent requests")}
{recentTraffic.map((e) => (
@@ -1128,11 +1146,11 @@ export default function DashboardPage() { {/* System status & pending approvals */} - System status + {t("System status")}
-
LLM config
+
{t("LLM config")}
- {stats?.llm_configured ? "Configured" : "Not configured"} + {stats?.llm_configured ? t("Configured") : t("Not configured")}
-
Traffic capture
+
{t("Traffic capture")}
- {settings?.traffic_capture ? "On" : "Off"} + {settings?.traffic_capture ? t("On") : t("Off")}
{activeProfile && (
-
Active model
+
{t("Active model")}
{activeProfile.model}
)} @@ -1172,7 +1190,9 @@ export default function DashboardPage() { {/* pending approvals */} {pendingCount > 0 && (
-
Pending approvals ({pendingCount})
+
+ {t("Pending approvals ({count})", { count: pendingCount })} +
{pending.slice(0, 3).map((p) => ( - {pendingCount - 3} more… + {t("{count} more…", { count: pendingCount - 3 })} )}
@@ -1202,7 +1222,7 @@ export default function DashboardPage() { {pendingCount === 0 && (
- No pending interception approvals + {t("No pending interception approvals")}
)} diff --git a/web/src/app/(main)/function/assets/page.tsx b/web/src/app/(main)/function/assets/page.tsx index 6d70f91..bbbe6f9 100644 --- a/web/src/app/(main)/function/assets/page.tsx +++ b/web/src/app/(main)/function/assets/page.tsx @@ -63,6 +63,7 @@ import { parseCompanyScopeText } from "@/lib/company-scope"; import { httpHref } from "@/lib/http-href"; import type { Asset, Company, CompanyScopeRule } from "@/lib/types"; import { cn } from "@/lib/utils"; +import { t } from "@/i18n"; const METHOD_COLOR: Record = { GET: "bg-emerald-100 text-emerald-700", @@ -99,13 +100,13 @@ function statusTone(code: number) { const PAGE_SIZES = [25, 50, 100, 200]; const TABS: { key: string; label: string; icon: LucideIcon }[] = [ - { key: "company", label: "Companies", icon: BuildingIcon }, - { key: "root_domain", label: "Root domains", icon: GlobeIcon }, + { key: "company", label: t("Companies"), icon: BuildingIcon }, + { key: "root_domain", label: t("Root domains"), icon: GlobeIcon }, { key: "ip", label: "IP", icon: NetworkIcon }, - { key: "subdomain", label: "Subdomains", icon: GlobeIcon }, - { key: "app", label: "Apps", icon: SmartphoneIcon }, - { key: "service", label: "Services", icon: LayoutTemplateIcon }, - { key: "endpoint", label: "Endpoints", icon: LinkIcon }, + { key: "subdomain", label: t("Subdomains"), icon: GlobeIcon }, + { key: "app", label: t("Apps"), icon: SmartphoneIcon }, + { key: "service", label: t("Services"), icon: LayoutTemplateIcon }, + { key: "endpoint", label: t("Endpoints"), icon: LinkIcon }, ]; export default function AssetsPage() { @@ -193,11 +194,11 @@ export default function AssetsPage() { setDeleting(true); try { const res = await api.deleteAssets(deleteIds); - toast.success(`Deleted ${res.deleted} assets`); + toast.success(t("Deleted {count} assets", { count: res.deleted })); setSelected(new Set()); refresh(); } catch (e) { - toast.error("Delete failed: " + String((e as Error)?.message ?? e)); + toast.error(t("Delete failed: {error}", { error: String((e as Error)?.message ?? e) })); } finally { setDeleting(false); setDeleteOpen(false); @@ -211,12 +212,12 @@ export default function AssetsPage() { const res = await api.deleteCompany(companyDeleteTarget.id, companyDeleteAssets); const msg = companyDeleteAssets && res.assets_deleted > 0 - ? `Company deleted, along with ${res.assets_deleted} assets` - : "Company deleted"; + ? t("Company deleted, along with {count} assets", { count: res.assets_deleted }) + : t("Company deleted"); toast.success(msg); refresh(); } catch (e) { - toast.error("Delete failed: " + String((e as Error)?.message ?? e)); + toast.error(t("Delete failed: {error}", { error: String((e as Error)?.message ?? e) })); } finally { setCompanyDeleting(false); setCompanyDeleteTarget(null); @@ -317,19 +318,19 @@ export default function AssetsPage() {
-

Assets

+

{t("Assets")}

- - {totalAssets} assets in total + + {t("{count} assets in total", { count: totalAssets })} {selected.size > 0 && ( )}
@@ -355,10 +356,10 @@ export default function AssetsPage() { - Company - Assets - Asset scope - Actions + {t("Company")} + {t("Assets")} + {t("Asset scope")} + {t("Actions")} @@ -381,7 +382,7 @@ export default function AssetsPage() { ))} ) : ( - No scope set + {t("No scope set")} )} @@ -396,7 +397,7 @@ export default function AssetsPage() { setCompanyDeleteTarget(c); setCompanyDeleteAssets(false); }} - aria-label={`Delete company ${c.name}`} + aria-label={t("Delete company {name}", { name: c.name })} > @@ -407,7 +408,9 @@ export default function AssetsPage() { {companies.length === 0 && ( - No companies yet. Click "Add company" in the top-right corner and fill in the asset scope; the system will automatically claim matching assets. + {t( + 'No companies yet. Click "Add company" in the top-right corner and fill in the asset scope; the system will automatically claim matching assets.', + )} )} @@ -440,7 +443,7 @@ export default function AssetsPage() { {a.domain} {a.icp || "—"} - {companyName(a.company_id) || Unassigned} + {companyName(a.company_id) || {t("Unassigned")}} @@ -495,7 +498,7 @@ export default function AssetsPage() { size="icon" className="size-7 text-muted-foreground hover:text-destructive" onClick={() => openDelete([a.id])} - aria-label={`Delete asset ${a.ip || a.id}`} + aria-label={t("Delete asset {name}", { name: a.ip || a.id })} > @@ -537,7 +540,7 @@ export default function AssetsPage() { size="icon" className="size-7 text-muted-foreground hover:text-destructive" onClick={() => openDelete([a.id])} - aria-label={`Delete asset ${a.domain || a.id}`} + aria-label={t("Delete asset {name}", { name: a.domain || a.id })} > @@ -577,7 +580,7 @@ export default function AssetsPage() { size="icon" className="size-7 text-muted-foreground hover:text-destructive" onClick={() => openDelete([a.id])} - aria-label={`Delete asset ${a.app_name || a.id}`} + aria-label={t("Delete asset {name}", { name: a.app_name || a.id })} > @@ -657,7 +660,7 @@ export default function AssetsPage() { ) : ( (a.auth ?? []).map((authItem, i) => { const item = authItem as Record; - const label = item.type || item.username || "Auth"; + const label = item.type || item.username || t("Auth"); return ( @@ -673,7 +676,7 @@ export default function AssetsPage() { size="icon" className="size-7 text-muted-foreground hover:text-destructive" onClick={() => openDelete([a.id])} - aria-label={`Delete asset ${a.url || a.id}`} + aria-label={t("Delete asset {name}", { name: a.url || a.id })} > @@ -725,7 +728,7 @@ export default function AssetsPage() { size="icon" className="size-7 text-muted-foreground hover:text-destructive" onClick={() => openDelete([a.id])} - aria-label={`Delete asset ${a.url || a.id}`} + aria-label={t("Delete asset {name}", { name: a.url || a.id })} > @@ -739,14 +742,15 @@ export default function AssetsPage() { - Confirm delete + {t("Confirm delete")} - This will permanently delete {deleteIds.length}{" "} - asset records. This action cannot be undone. + {t("This will permanently delete {count} asset records. This action cannot be undone.", { + count: deleteIds.length, + })} - Cancel + {t("Cancel")} { e.preventDefault(); @@ -755,7 +759,7 @@ export default function AssetsPage() { disabled={deleting} className="bg-destructive text-destructive-foreground hover:bg-destructive/90" > - {deleting ? "Deleting…" : "Confirm delete"} + {deleting ? t("Deleting…") : t("Confirm delete")} @@ -772,10 +776,14 @@ export default function AssetsPage() { > - Delete company · {companyDeleteTarget?.name} + {t("Delete company · {name}", { name: companyDeleteTarget?.name ?? "" })}
-

This will permanently delete the company and its asset scope configuration. This action cannot be undone.

+

+ {t( + "This will permanently delete the company and its asset scope configuration. This action cannot be undone.", + )} +

- Cancel + {t("Cancel")} { e.preventDefault(); @@ -803,7 +813,7 @@ export default function AssetsPage() { disabled={companyDeleting} className="bg-destructive text-destructive-foreground hover:bg-destructive/90" > - {companyDeleting ? "Deleting…" : "Confirm delete"} + {companyDeleting ? t("Deleting…") : t("Confirm delete")}
@@ -861,7 +871,7 @@ function AssetCard({ /> ) : ( - {c} + {c && t(c)} ), )} @@ -872,7 +882,7 @@ function AssetCard({ ) : ( - {loaded ? "No data." : "Loading…"} + {loaded ? t("No data.") : t("Loading…")} )} @@ -889,7 +899,7 @@ function AssetCard({ {PAGE_SIZES.map((n) => ( - {n} / page + {t("{count} / page", { count: n })} ))} @@ -989,11 +999,11 @@ function CompanyDialog({ onSaved }: { onSaved: () => void }) { const submit = async () => { if (!name.trim()) { - toast.error("Please enter a company name"); + toast.error(t("Please enter a company name")); return; } if (parsedScope.errors.length > 0) { - toast.error("Please fix the invalid asset scope"); + toast.error(t("Please fix the invalid asset scope")); return; } setBusy(true); @@ -1001,14 +1011,15 @@ function CompanyDialog({ onSaved }: { onSaved: () => void }) { const res = await api.createCompany(name.trim(), parsedScope.rules); const added = res.scope_added ?? 0; const invalid = res.scope_invalid ?? 0; - if (invalid > 0) toast.warning(`Company created, ${added} scopes added; ${invalid} invalid lines`); - else toast.success(`Company created, ${added} scopes added`); + if (invalid > 0) + toast.warning(t("Company created, {added} scopes added; {invalid} invalid lines", { added, invalid })); + else toast.success(t("Company created, {added} scopes added", { added })); setOpen(false); onSaved(); } catch (e) { const msg = String((e as Error)?.message ?? e); - if (/:\s*409$/.test(msg)) toast.error("Company already exists; try a different name"); - else toast.error(`Save failed: ${msg}`); + if (/:\s*409$/.test(msg)) toast.error(t("Company already exists; try a different name")); + else toast.error(t("Save failed: {error}", { error: msg })); } finally { setBusy(false); } @@ -1018,21 +1029,25 @@ function CompanyDialog({ onSaved }: { onSaved: () => void }) { - Add company - Configure the company and its asset scope. Keywords only serve as agent hints and do not automatically assign assets. + {t("Add company")} + + {t( + "Configure the company and its asset scope. Keywords only serve as agent hints and do not automatically assign assets.", + )} +
- Company name + {t("Company name")} setName(e.target.value)} /> @@ -1042,10 +1057,10 @@ function CompanyDialog({ onSaved }: { onSaved: () => void }) {
@@ -1073,20 +1088,20 @@ function EditScopeDialog({ company, onSaved }: { company: Company; onSaved: () = const submit = async () => { if (parsedScope.errors.length > 0) { - toast.error("Please fix the invalid asset scope"); + toast.error(t("Please fix the invalid asset scope")); return; } setBusy(true); try { const res = await api.updateCompanyScope(company.id, parsedScope.rules, reason); const errCount = res.invalid ?? 0; - if (errCount > 0) toast.warning(`Saved; ${errCount} invalid lines`); - else toast.success(`Scope updated, ${res.added} entries in total`); + if (errCount > 0) toast.warning(t("Saved; {count} invalid lines", { count: errCount })); + else toast.success(t("Scope updated, {count} entries in total", { count: res.added })); showScopeWarnings(res.warnings); setOpen(false); onSaved(); } catch (e) { - toast.error(`Save failed: ${String((e as Error)?.message ?? e)}`); + toast.error(t("Save failed: {error}", { error: String((e as Error)?.message ?? e) })); } finally { setBusy(false); } @@ -1096,14 +1111,16 @@ function EditScopeDialog({ company, onSaved }: { company: Company; onSaved: () = - Edit asset scope · {company.name} + {t("Edit asset scope · {name}", { name: company.name })} - Saving replaces all existing scopes. ICP matches assets exactly; company keywords only serve as agent hints. + {t( + "Saving replaces all existing scopes. ICP matches assets exactly; company keywords only serve as agent hints.", + )} @@ -1114,10 +1131,10 @@ function EditScopeDialog({ company, onSaved }: { company: Company; onSaved: () = parsed={parsedScope} /> - Attribution basis (optional) + {t("Attribution basis (optional)")} setReason(e.target.value)} /> @@ -1125,10 +1142,10 @@ function EditScopeDialog({ company, onSaved }: { company: Company; onSaved: () = @@ -1152,24 +1169,24 @@ function AppendScopeDialog({ company, onSaved }: { company: Company; onSaved: () const submit = async () => { if (parsedScope.rules.length === 0) { - toast.error("Please enter the scopes to append"); + toast.error(t("Please enter the scopes to append")); return; } if (parsedScope.errors.length > 0) { - toast.error("Please fix the invalid asset scope"); + toast.error(t("Please fix the invalid asset scope")); return; } setBusy(true); try { const res = await api.addCompanyScope(company.id, parsedScope.rules, reason); const errCount = res.invalid ?? 0; - if (errCount > 0) toast.warning(`Saved; ${errCount} invalid lines`); - else toast.success(`Appended ${res.added} scopes`); + if (errCount > 0) toast.warning(t("Saved; {count} invalid lines", { count: errCount })); + else toast.success(t("Appended {count} scopes", { count: res.added })); showScopeWarnings(res.warnings); setOpen(false); onSaved(); } catch (e) { - toast.error(`Save failed: ${String((e as Error)?.message ?? e)}`); + toast.error(t("Save failed: {error}", { error: String((e as Error)?.message ?? e) })); } finally { setBusy(false); } @@ -1179,13 +1196,17 @@ function AppendScopeDialog({ company, onSaved }: { company: Company; onSaved: () - Append asset scope · {company.name} - New scopes are appended to the existing ones. ICP matches assets exactly; company keywords only serve as agent hints. + {t("Append asset scope · {name}", { name: company.name })} + + {t( + "New scopes are appended to the existing ones. ICP matches assets exactly; company keywords only serve as agent hints.", + )} + - Attribution basis (optional) + {t("Attribution basis (optional)")} setReason(e.target.value)} /> @@ -1206,10 +1227,10 @@ function AppendScopeDialog({ company, onSaved }: { company: Company; onSaved: () diff --git a/web/src/app/(main)/function/commands/page.tsx b/web/src/app/(main)/function/commands/page.tsx index e12a06e..9f7d7c2 100644 --- a/web/src/app/(main)/function/commands/page.tsx +++ b/web/src/app/(main)/function/commands/page.tsx @@ -15,9 +15,10 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@ import { api } from "@/lib/api"; import type { CommandRecord, ToolStat } from "@/lib/types"; import { cn } from "@/lib/utils"; +import { intlLocale, t } from "@/i18n"; function fmtTime(ts: string) { - return new Date(ts).toLocaleString("zh-CN", { + return new Date(ts).toLocaleString(intlLocale, { month: "2-digit", day: "2-digit", hour: "2-digit", @@ -130,7 +131,7 @@ export default function CommandsPage() {
-

Tool executions

+

{t("Tool executions")}

{total}
@@ -140,14 +141,14 @@ export default function CommandsPage() {
setQuery(e.target.value)} className="h-8 pl-8" />
setTaskFilter(e.target.value.replace(/\D/g, ""))} @@ -159,7 +160,7 @@ export default function CommandsPage() { {PAGE_SIZES.map((n) => ( - {n} / page + {t("{count} / page", { count: n })} ))} @@ -167,7 +168,7 @@ export default function CommandsPage() {
@@ -205,12 +206,12 @@ export default function CommandsPage() {
- Time - Task - Worker - Tool - Input - Status + {t("Time")} + {t("Task")} + {t("Worker")} + {t("Tool")} + {t("Input")} + {t("Status")} @@ -223,7 +224,7 @@ export default function CommandsPage() { ) : commands.length === 0 ? ( - No tool execution records yet + {t("No tool execution records yet")} ) : ( @@ -255,11 +256,11 @@ export default function CommandsPage() { {cmd.is_error ? ( - Failed + {t("Failed")} ) : ( - Success + {t("Success")} )} @@ -276,21 +277,20 @@ export default function CommandsPage() { - Tool call stats + {t("Tool call stats")} - {taskFilter || queryQ ? "All records under the current filters" : "All tool execution records"} + {taskFilter || queryQ ? t("All records under the current filters") : t("All tool execution records")} {stats.length > 0 && ( - <> + {" · "} - {stats.length} tools ·{" "} - {statsTotal} calls + {t("{tools} tools · {calls} calls", { tools: stats.length, calls: statsTotal })} {statsErrors > 0 && ( <> - {" · Failed "} - {statsErrors} + {" · "} + {t("Failed {count}", { count: statsErrors })} )} - + )} @@ -300,7 +300,7 @@ export default function CommandsPage() { ) : stats.length === 0 ? ( -
No stats data
+
{t("No stats data")}
) : (
{stats.map((s) => ( @@ -309,7 +309,9 @@ export default function CommandsPage() {
{s.tool} {s.errors > 0 && ( - Failed {s.errors} + + {t("Failed {count}", { count: s.errors })} + )}
@@ -337,7 +339,7 @@ export default function CommandsPage() { {selected && ( <> - Tool execution details + {t("Tool execution details")} {fmtTime(selected.created_at)}
@@ -351,18 +353,18 @@ export default function CommandsPage() { {selected.is_error ? ( - Failed + {t("Failed")} ) : ( - Success + {t("Success")} )}
-
Input
+
{t("Input")}
                       {toolInput(selected.command)}
@@ -370,7 +372,7 @@ export default function CommandsPage() {
                   
-
Output
+
{t("Output")}
-                      {selected.output || "(empty)"}
+                      {selected.output || t("(empty)")}
                     
diff --git a/web/src/app/(main)/function/findings/_components/asset-tree.tsx b/web/src/app/(main)/function/findings/_components/asset-tree.tsx index 13f636e..13433e0 100644 --- a/web/src/app/(main)/function/findings/_components/asset-tree.tsx +++ b/web/src/app/(main)/function/findings/_components/asset-tree.tsx @@ -20,6 +20,7 @@ import { Button } from "@/components/ui/button"; import { InputGroup, InputGroupAddon, InputGroupInput } from "@/components/ui/input-group"; import type { FindingAssetKind, FindingAssetNode } from "@/lib/types"; import { cn } from "@/lib/utils"; +import { t } from "@/i18n"; // Icons reuse the assets page's type mapping, so the same asset kind looks the same in both places. const KIND_ICON: Record = { @@ -34,14 +35,14 @@ const KIND_ICON: Record = { }; const KIND_LABEL: Record = { - company: "Company", - root_domain: "Root domain", - subdomain: "Subdomain", + company: t("Company"), + root_domain: t("Root domain"), + subdomain: t("Subdomain"), ip: "IP", - app: "App", - service: "Service", - endpoint: "Endpoint", - none: "Unlinked", + app: t("App"), + service: t("Service"), + endpoint: t("Endpoint"), + none: t("Unlinked"), }; // TreeNode is the tree assembled from the node array. The backend already sorts by "most findings under the same parent first", @@ -233,9 +234,9 @@ export function AssetTree({ [isExpanded], ); - let emptyHint = "No findings are linked to assets under the current filters."; - if (loading) emptyHint = "Loading…"; - else if (searching) emptyHint = "No matching assets."; + let emptyHint = t("No findings are linked to assets under the current filters."); + if (loading) emptyHint = t("Loading…"); + else if (searching) emptyHint = t("No matching assets."); const rows: React.ReactNode[] = []; const pushRows = (list: TreeNode[]) => { @@ -264,8 +265,8 @@ export function AssetTree({ type="search" value={keyword} onChange={(event) => setKeyword(event.target.value)} - placeholder="Filter assets" - aria-label="Filter assets" + placeholder={t("Filter assets")} + aria-label={t("Filter assets")} />
@@ -343,7 +346,7 @@ function AssetTreeRow({ type="button" onClick={onToggle} className="flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground" - aria-label={open ? "Collapse" : "Expand"} + aria-label={open ? t("Collapse") : t("Expand")} aria-expanded={open} > @@ -362,16 +365,16 @@ function AssetTreeRow({ {node.critical > 0 && ( - + {node.critical} )} {node.high > 0 && ( - + {node.high} )} - + {node.total} diff --git a/web/src/app/(main)/function/findings/_components/findings-table.tsx b/web/src/app/(main)/function/findings/_components/findings-table.tsx index 56b7b5b..7eab950 100644 --- a/web/src/app/(main)/function/findings/_components/findings-table.tsx +++ b/web/src/app/(main)/function/findings/_components/findings-table.tsx @@ -46,6 +46,7 @@ import type { VerificationStatus, } from "@/lib/types"; import { cn } from "@/lib/utils"; +import { intlLocale, t } from "@/i18n"; export const SEVERITIES: Severity[] = ["critical", "high", "medium", "low"]; @@ -78,11 +79,11 @@ export const FINDING_REPORT_STATES: FindingReportState[] = [ ]; export const REPORT_STATE_META: Record = { - none: { label: "Not submitted", tone: "slate" }, - submitted: { label: "Submitted", tone: "amber" }, - accepted: { label: "Accepted", tone: "green" }, - rejected: { label: "Rejected", tone: "red" }, - duplicate: { label: "Duplicate report", tone: "neutral" }, + none: { label: t("Not submitted"), tone: "slate" }, + submitted: { label: t("Submitted"), tone: "amber" }, + accepted: { label: t("Accepted"), tone: "green" }, + rejected: { label: t("Rejected"), tone: "red" }, + duplicate: { label: t("Duplicate report"), tone: "neutral" }, }; export function ReportStateBadge({ state }: { state?: FindingReportState }) { @@ -102,11 +103,11 @@ export function ReportStateBadge({ state }: { state?: FindingReportState }) { // Verification outcome → label/tone, on the same tone tokens StatusBadge uses. export const VERIFICATION_META: Record = { - verified: { label: "Verified", tone: "green" }, - unverified: { label: "Unverified", tone: "slate" }, - blocked: { label: "Blocked", tone: "amber" }, - not_assessed: { label: "Not assessed", tone: "red" }, - false_positive: { label: "False positive", tone: "neutral" }, + verified: { label: t("Verified"), tone: "green" }, + unverified: { label: t("Unverified"), tone: "slate" }, + blocked: { label: t("Blocked"), tone: "amber" }, + not_assessed: { label: t("Not assessed"), tone: "red" }, + false_positive: { label: t("False positive"), tone: "neutral" }, }; // VerificationBadge shows the automated verification outcome ("Verified L3" when a @@ -155,7 +156,7 @@ export function isSameFinding(left: Finding, right: Finding): boolean { } export function fmtTime(ts: string) { - return new Date(ts).toLocaleString("zh-CN", { + return new Date(ts).toLocaleString(intlLocale, { month: "2-digit", day: "2-digit", hour: "2-digit", @@ -208,7 +209,7 @@ export function FindingsTable({ activeRetests, onDeepen, onDelete, - selectAllLabel = "Select all on this page", + selectAllLabel = t("Select all on this page"), }: FindingsTableProps) { const selectableIds = items.map((finding) => finding.finding_id).filter((id): id is string => Boolean(id)); const selectedCount = selectableIds.filter((id) => selectedIds.has(id)).length; @@ -232,14 +233,14 @@ export function FindingsTable({ /> - Severity - Vulnerability - Asset - Status - Report - Task - Time - Actions + {t("Severity")} + {t("Vulnerability")} + {t("Asset")} + {t("Status")} + {t("Report")} + {t("Task")} + {t("Time")} + {t("Actions")} @@ -266,7 +267,7 @@ export function FindingsTable({ onToggleSelected(f.finding_id as string, c === true)} - aria-label="Select this vulnerability" + aria-label={t("Select this vulnerability")} /> )} @@ -285,16 +286,16 @@ export function FindingsTable({ href={`/function/findings/detail?id=${f.finding_id}`} onClick={(e) => e.stopPropagation()} className="truncate font-medium hover:text-primary hover:underline" - title="View finding details" + title={t("View finding details")} > - {f.name || f.vulnclass || "Uncategorized"} + {f.name || f.vulnclass || t("Uncategorized")} ) : ( - {f.name || f.vulnclass || "Uncategorized"} + {f.name || f.vulnclass || t("Uncategorized")} )} {f.summary}
- Traffic evidence: {f.traffic_count ?? 0} + {t("Traffic evidence: {count}", { count: f.traffic_count ?? 0 })}
@@ -378,22 +379,27 @@ export function FindingsTable({
{retest ? ( ) : null} {!retest && f.finding_id && !f.inherited ? ( - ) : null} {f.finding_id && f.task_id && ( )} {f.finding_id && ( @@ -403,25 +409,24 @@ export function FindingsTable({ size="icon" variant="ghost" className="size-7 text-muted-foreground hover:text-destructive" - aria-label="Delete vulnerability" + aria-label={t("Delete vulnerability")} > - Delete this vulnerability? - - " - - {f.name || f.vulnclass || f.summary || `#${f.finding_id}`} - - " will be permanently deleted and removed from the findings list, the task findings tab, and the exploration graph. This action cannot be undone. + {t("Delete this vulnerability?")} + + {t( + '"{name}" will be permanently deleted and removed from the findings list, the task findings tab, and the exploration graph. This action cannot be undone.', + { name: f.name || f.vulnclass || f.summary || `#${f.finding_id}` }, + )} - Cancel - onDelete(f)}>Delete + {t("Cancel")} + onDelete(f)}>{t("Delete")} @@ -439,23 +444,23 @@ export function FindingsTable({ {f.finding_id && edit && (
- + onEditChange((s) => (s ? { ...s, name: e.target.value } : s))} - placeholder="Readable title; falls back to category when empty" + placeholder={t("Readable title; falls back to category when empty")} />
- + onEditChange((s) => (s ? { ...s, vulnclass: e.target.value } : s))} - placeholder="e.g. SQL Injection" + placeholder={t("e.g. SQL Injection")} />
- +
)}
- Evidence + {t("Evidence")} {f.vulnclass && ( - · Type: + · {t("Type:")} {f.vulnclass} )} {f.param_id && {f.param_id}} {f.assets && f.assets.length > 0 && ( - · Assets: + · {t("Assets:")} {f.assets.map((a) => ( {a.label} @@ -508,12 +513,12 @@ export function FindingsTable({
- Detailed report + {t("Detailed report")} {reports[rowKey]?.status === "done" && reports[rowKey]?.text.trim() && ( @@ -522,11 +527,11 @@ export function FindingsTable({ {(() => { const rep = reports[rowKey]; if (!rep || rep.status === "loading") - return

Loading…

; + return

{t("Loading…")}

; if (rep.status === "error") - return

Failed to load the report.

; + return

{t("Failed to load the report.")}

; if (!rep.text.trim()) - return

No detailed report yet.

; + return

{t("No detailed report yet.")}

; return ( // break-words inherits into paragraphs/lists; pre additionally gets // whitespace-pre-wrap so code blocks wrap too — otherwise long code lines/URLs @@ -548,7 +553,7 @@ export function FindingsTable({ {items.length === 0 && ( - No matching findings. + {t("No matching findings.")} )} diff --git a/web/src/app/(main)/function/findings/detail/lineage.tsx b/web/src/app/(main)/function/findings/detail/lineage.tsx index 97b4438..982e12b 100644 --- a/web/src/app/(main)/function/findings/detail/lineage.tsx +++ b/web/src/app/(main)/function/findings/detail/lineage.tsx @@ -5,6 +5,7 @@ import * as React from "react"; import { ExplorationGraph } from "@/components/exploration-graph"; import { api } from "@/lib/api"; import type { Edge, TaskNode } from "@/lib/types"; +import { t } from "@/i18n"; // FindingLineageView renders the exploration sub-graph from the task's initial // node down to this finding's node — the same exploration graph canvas as the task graph, @@ -35,7 +36,7 @@ export function FindingLineageView({ findingId }: { findingId: string }) { if (loaded && nodes.length === 0) { return (

- No lineage to display (this vulnerability is not linked to an exploration node, or its task has been deleted). + {t("No lineage to display (this vulnerability is not linked to an exploration node, or its task has been deleted).")}

); } @@ -45,7 +46,7 @@ export function FindingLineageView({ findingId }: { findingId: string }) { nodes={nodes} edges={edges} className="h-[68vh]" - emptyHint={loaded ? "No lineage" : "Loading…"} + emptyHint={loaded ? t("No lineage") : t("Loading…")} /> ); } diff --git a/web/src/app/(main)/function/findings/detail/page.tsx b/web/src/app/(main)/function/findings/detail/page.tsx index d33e516..2950054 100644 --- a/web/src/app/(main)/function/findings/detail/page.tsx +++ b/web/src/app/(main)/function/findings/detail/page.tsx @@ -24,6 +24,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { api } from "@/lib/api"; import { statusMeta } from "@/lib/status"; import type { Finding, FindingReportState, FindingStatus, Severity } from "@/lib/types"; +import { intlLocale, t } from "@/i18n"; import { FINDING_REPORT_STATES, @@ -47,7 +48,7 @@ const FINDING_STATUSES: FindingStatus[] = [ ]; function fmtTime(ts: string) { - return new Date(ts).toLocaleString("zh-CN"); + return new Date(ts).toLocaleString(intlLocale); } // FieldRow is one label/value line in the right-hand status panel. @@ -91,10 +92,10 @@ function FindingDetailInner() { try { const updated = await api.setFindingSeverity(id, next); setFinding(updated); - toast.success(`Severity changed to "${statusMeta("severity", next).label}"`); + toast.success(t('Severity changed to "{label}"', { label: statusMeta("severity", next).label })); } catch (e) { setFinding((cur) => (cur ? { ...cur, severity: prev } : cur)); - toast.error("Update failed: " + (e as Error).message); + toast.error(t("Update failed: {error}", { error: (e as Error).message })); } }, [finding, id], @@ -108,10 +109,10 @@ function FindingDetailInner() { try { const updated = await api.setFindingStatus(id, next); setFinding(updated); - toast.success(`Status changed to "${statusMeta("finding", next).label}"`); + toast.success(t('Status changed to "{label}"', { label: statusMeta("finding", next).label })); } catch (e) { setFinding((cur) => (cur ? { ...cur, status: prev } : cur)); - toast.error("Update failed: " + (e as Error).message); + toast.error(t("Update failed: {error}", { error: (e as Error).message })); } }, [finding, id], @@ -125,10 +126,10 @@ function FindingDetailInner() { try { const updated = await api.setFindingReportState(id, next); setFinding(updated); - toast.success(`Report stage changed to "${REPORT_STATE_META[next].label}"`); + toast.success(t('Report stage changed to "{label}"', { label: REPORT_STATE_META[next].label })); } catch (e) { setFinding((cur) => (cur ? { ...cur, report_state: prev } : cur)); - toast.error("Update failed: " + (e as Error).message); + toast.error(t("Update failed: {error}", { error: (e as Error).message })); } }, [finding, id], @@ -137,11 +138,11 @@ function FindingDetailInner() { if (!finding) { return (
-

{loaded ? `Finding ${id} not found` : "Loading…"}

+

{loaded ? t("Finding {id} not found", { id }) : t("Loading…")}

{loaded && ( )} @@ -149,7 +150,7 @@ function FindingDetailInner() { ); } - const title = finding.name || finding.vulnclass || "Uncategorized"; + const title = finding.name || finding.vulnclass || t("Uncategorized"); return ( @@ -173,12 +174,12 @@ function FindingDetailInner() { {finding.inherited && finding.source_task_id && ( - Source task #{finding.source_task_id} · read-only + {t("Source task #{id} · read-only", { id: finding.source_task_id })} )}
- Overview - Exploration graph + {t("Overview")} + {t("Exploration graph")} @@ -191,16 +192,16 @@ function FindingDetailInner() {
- Digest + {t("Digest")} -

{finding.summary || "(no digest)"}

+

{finding.summary || t("(no digest)")}

- Evidence / PoC + {t("Evidence / PoC")} {finding.evidence ? ( @@ -208,14 +209,14 @@ function FindingDetailInner() { {finding.evidence} ) : ( -

(no evidence)

+

{t("(no evidence)")}

)}
{finding.counterevidence?.trim() && ( - Counterevidence + {t("Counterevidence")}

{finding.counterevidence}

@@ -225,7 +226,7 @@ function FindingDetailInner() { {finding.confidence_rationale?.trim() && ( - Confidence rationale + {t("Confidence rationale")}

{finding.confidence_rationale}

@@ -242,19 +243,21 @@ function FindingDetailInner() { {/* Below evidence: detailed report (rendered Markdown) */} - Detailed report - {finding.report && } + {t("Detailed report")} + {finding.report && } {finding.report_stale ? ( - Traffic evidence has changed; the detailed report is pending an update. + + {t("Traffic evidence has changed; the detailed report is pending an update.")} + ) : null} {finding.report ? ( ) : ( -

No detailed report yet.

+

{t("No detailed report yet.")}

)}
@@ -263,18 +266,18 @@ function FindingDetailInner() { {/* Right column: status panel */} - Status + {t("Status")} {/* Vulnerability ID */} - + #{finding.id} {/* Severity */} - + {finding.inherited ? ( ) : ( @@ -296,7 +299,7 @@ function FindingDetailInner() { {/* Triage status */} - + {finding.inherited ? ( ) : ( @@ -317,7 +320,7 @@ function FindingDetailInner() { )} - + {finding.inherited ? ( ) : ( @@ -343,7 +346,7 @@ function FindingDetailInner() { {/* Verification: automated outcome; the note explains any state other than verified */} {finding.verification_status && ( - + {finding.verification_status !== "verified" && finding.verification_note?.trim() && (

@@ -354,7 +357,7 @@ function FindingDetailInner() { )} {/* Vulnerability type */} - + {finding.vulnclass ? ( {finding.vulnclass} ) : ( @@ -363,7 +366,7 @@ function FindingDetailInner() { {/* Assets */} - + {finding.assets && finding.assets.length > 0 ? (

{finding.assets.map((a) => ( @@ -382,7 +385,7 @@ function FindingDetailInner() { {/* Task */} - + {finding.task_id ? ( ) : ( - — (task deleted) + {t("— (task deleted)")} )} {/* Found at */} - + {fmtTime(finding.ts)} diff --git a/web/src/app/(main)/function/findings/page.tsx b/web/src/app/(main)/function/findings/page.tsx index 25eb1c1..bd1dfd1 100644 --- a/web/src/app/(main)/function/findings/page.tsx +++ b/web/src/app/(main)/function/findings/page.tsx @@ -73,6 +73,7 @@ import { VERIFICATION_STATUSES, } from "./_components/findings-table"; import { setVisibleInterval } from "@/lib/polling"; +import { t } from "@/i18n"; const FINDING_LIST_PREFERENCE_KEY = "artex_finding_list_preferences"; @@ -201,7 +202,7 @@ export default function FindingsPage() { setActiveRetests(Object.fromEntries(rows.map((item) => [item.finding_id, item]))); failed = false; } catch (error) { - if (!disposed && !failed) toast.error(`Failed to load retest status: ${(error as Error).message}`); + if (!disposed && !failed) toast.error(t("Failed to load retest status: {error}", { error: (error as Error).message })); failed = true; } finally { if (!disposed) timer = setTimeout(() => void refreshRetests(), 3000); @@ -324,9 +325,9 @@ export default function FindingsPage() { ids: [...selectedIds], }); setExportOpen(false); - toast.success("Export download started"); + toast.success(t("Export download started")); } catch (e) { - toast.error(`Export failed: ${(e as Error).message}`); + toast.error(t("Export failed: {error}", { error: (e as Error).message })); } finally { setExporting(false); } @@ -420,7 +421,7 @@ export default function FindingsPage() { } catch (e) { if (request !== assetTreeRequest.current || activeFilterFingerprint.current !== requestFilter) return; setAssetTree((current) => ({ ...current, loading: false })); - toast.error(`Failed to load the asset tree: ${(e as Error).message}`); + toast.error(t("Failed to load the asset tree: {error}", { error: (e as Error).message })); } }, [filterFingerprint, reportState, severity, status, verificationStatus, vulnclass, task, query, sort]); @@ -669,7 +670,7 @@ export default function FindingsPage() { setFindings((cur) => cur.map((x) => (isSameFinding(x, f) ? { ...x, status: next } : x))); try { await api.setFindingStatus(f.finding_id, next); - toast.success(`Marked as "${statusMeta("finding", next).label}"`); + toast.success(t('Marked as "{label}"', { label: statusMeta("finding", next).label })); // refresh stat cards (pending count) and drop the row if it no longer matches the status filter api .findingStats() @@ -685,7 +686,7 @@ export default function FindingsPage() { refreshAfterMutation(f); } catch (e) { setFindings((cur) => cur.map((x) => (isSameFinding(x, f) ? { ...x, status: prev } : x))); - toast.error(`Update failed: ${(e as Error).message}`); + toast.error(t("Update failed: {error}", { error: (e as Error).message })); } }, [refreshAfterMutation, setFindings, status], @@ -698,7 +699,7 @@ export default function FindingsPage() { setFindings((cur) => cur.map((x) => (isSameFinding(x, f) ? { ...x, report_state: next } : x))); try { await api.setFindingReportState(f.finding_id, next); - toast.success(`Report stage set to "${REPORT_STATE_META[next].label}"`); + toast.success(t('Report stage set to "{label}"', { label: REPORT_STATE_META[next].label })); api .findingStats() .then(setStats) @@ -713,7 +714,7 @@ export default function FindingsPage() { refreshAfterMutation(f); } catch (e) { setFindings((cur) => cur.map((x) => (isSameFinding(x, f) ? { ...x, report_state: prev } : x))); - toast.error(`Update failed: ${(e as Error).message}`); + toast.error(t("Update failed: {error}", { error: (e as Error).message })); } }, [refreshAfterMutation, reportState, setFindings], @@ -729,9 +730,7 @@ export default function FindingsPage() { const r = await api.bulkSetFindingStatus([...selectedIds], next); setSelectedIds(new Set()); const label = statusMeta("finding", next).label; - toast.success( - r.updated === 1 ? `Marked 1 finding as "${label}"` : `Marked ${r.updated} findings as "${label}"`, - ); + toast.success(t('Marked {count} findings as "{label}"', { count: r.updated, label })); void loadFlat(); if (view === "asset") void loadAssetTree(); api @@ -741,7 +740,7 @@ export default function FindingsPage() { // The list reload remains valid even if the aggregate refresh fails. }); } catch (e) { - toast.error(`Bulk update failed: ${(e as Error).message}`); + toast.error(t("Bulk update failed: {error}", { error: (e as Error).message })); } finally { setBulkBusy(false); } @@ -757,11 +756,7 @@ export default function FindingsPage() { const r = await api.bulkSetFindingReportState([...selectedIds], next); setSelectedIds(new Set()); const label = REPORT_STATE_META[next].label; - toast.success( - r.updated === 1 - ? `Set report stage of 1 finding to "${label}"` - : `Set report stage of ${r.updated} findings to "${label}"`, - ); + toast.success(t('Set report stage of {count} findings to "{label}"', { count: r.updated, label })); void loadFlat(); if (view === "asset") void loadAssetTree(); api @@ -771,7 +766,7 @@ export default function FindingsPage() { // The list reload remains valid even if the aggregate refresh fails. }); } catch (e) { - toast.error(`Bulk update failed: ${(e as Error).message}`); + toast.error(t("Bulk update failed: {error}", { error: (e as Error).message })); } finally { setBulkBusy(false); } @@ -828,7 +823,7 @@ export default function FindingsPage() { : x, ), ); - toast.success("Saved"); + toast.success(t("Saved")); api .findingStats() .then(setStats) @@ -837,7 +832,7 @@ export default function FindingsPage() { }); refreshAfterMutation(f); } catch (e) { - toast.error(`Save failed: ${(e as Error).message}`); + toast.error(t("Save failed: {error}", { error: (e as Error).message })); } finally { setSaving(false); } @@ -861,7 +856,7 @@ export default function FindingsPage() { setFlat((cur) => ({ ...cur, total: Math.max(0, cur.total - 1) })); const rowKey = findingRowKey(f); setExpanded((cur) => (cur === rowKey ? null : cur)); - toast.success("Vulnerability deleted"); + toast.success(t("Vulnerability deleted")); api .findingStats() .then(setStats) @@ -870,7 +865,7 @@ export default function FindingsPage() { }); refreshAfterMutation(f, true); } catch (e) { - toast.error(`Delete failed: ${(e as Error).message}`); + toast.error(t("Delete failed: {error}", { error: (e as Error).message })); } }, [refreshAfterMutation, setFindings], @@ -888,28 +883,28 @@ export default function FindingsPage() { const result = await api.deepenFinding(deepenFinding.finding_id, deepenDescription.trim()); toast.success( result.queued - ? `Deepen intent #${result.intent_id} has entered the task queue` - : `Created high-priority worker intent #${result.intent_id}`, + ? t("Deepen intent #{id} has entered the task queue", { id: result.intent_id }) + : t("Created high-priority worker intent #{id}", { id: result.intent_id }), ); refreshAfterMutation(deepenFinding); setDeepenFinding(null); setDeepenDescription(""); } catch (error) { - toast.error(`Submit failed: ${(error as Error).message}`); + toast.error(t("Submit failed: {error}", { error: (error as Error).message })); } finally { setDeepening(false); } } const statCards = [ - { label: "Total findings", value: stats.total, icon: BugIcon }, - { label: "Pending", value: stats.pending, tone: "text-amber-500", icon: ClockIcon }, - { label: "Submitted", value: stats.submitted, tone: "text-amber-500", icon: FileUpIcon }, - { label: "Accepted", value: stats.accepted, tone: "text-emerald-500", icon: CircleCheckIcon }, - { label: "Critical", value: stats.critical, tone: "text-rose-600", icon: ShieldAlertIcon }, - { label: "High", value: stats.high, tone: "text-red-500", icon: TriangleAlertIcon }, - { label: "Medium", value: stats.medium, tone: "text-amber-500", icon: TriangleAlertIcon }, - { label: "Low", value: stats.low, tone: "text-slate-500", icon: InfoIcon }, + { label: t("Total findings"), value: stats.total, icon: BugIcon }, + { label: t("Pending"), value: stats.pending, tone: "text-amber-500", icon: ClockIcon }, + { label: t("Submitted"), value: stats.submitted, tone: "text-amber-500", icon: FileUpIcon }, + { label: t("Accepted"), value: stats.accepted, tone: "text-emerald-500", icon: CircleCheckIcon }, + { label: t("Critical"), value: stats.critical, tone: "text-rose-600", icon: ShieldAlertIcon }, + { label: t("High"), value: stats.high, tone: "text-red-500", icon: TriangleAlertIcon }, + { label: t("Medium"), value: stats.medium, tone: "text-amber-500", icon: TriangleAlertIcon }, + { label: t("Low"), value: stats.low, tone: "text-slate-500", icon: InfoIcon }, ]; // The "current filter" count in the export dialog: both views share the same filters, only the counting source differs. @@ -949,7 +944,7 @@ export default function FindingsPage() {
) : ( <> - +
-

Findings

-

Cross-task vulnerability overview

+

{t("Findings")}

+

{t("Cross-task vulnerability overview")}

setView(v as FindingView)}> - All findings - By task - By asset + {t("All findings")} + {t("By task")} + {t("By asset")}
@@ -1006,8 +1001,8 @@ export default function FindingsPage() { type="search" value={search} onChange={(event) => setSearch(event.target.value)} - placeholder="Search findings" - aria-label="Search findings" + placeholder={t("Search findings")} + aria-label={t("Search findings")} />