Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Localize local environment settings (#3802)

gaokui201042ca852be35a
diff --git a/src/components/ConnectedWorkspacesSettings.test.ts b/src/components/ConnectedWorkspacesSettings.test.ts
index e5c08e284b..14e8efe026 100644
--- a/src/components/ConnectedWorkspacesSettings.test.ts
+++ b/src/components/ConnectedWorkspacesSettings.test.ts
@@ -185,3 +185,10 @@ it("a Cloud of the person's own has no lending control here, since this computer
expect(labels.filter(label => /Computer access for (My Cloud|Client A)|use this/.test(label))).toEqual([]);
expect(render().html).not.toContain("data-cloud-lending-link");
});
+
+it("shows local environment controls in Simplified Chinese", async () => {
+ stubEnvironments(); setLocale("zh"); await mount();
+ const { html } = render();
+ expect(html).toContain("每个环境都有自己的机器人、会话和数据文件夹");
+ expect(html).not.toContain("Separate setups on this computer");
+});
diff --git a/src/components/ConnectedWorkspacesSettings.tsx b/src/components/ConnectedWorkspacesSettings.tsx
index b50dcdc426..cfbfb15639 100644
--- a/src/components/ConnectedWorkspacesSettings.tsx
+++ b/src/components/ConnectedWorkspacesSettings.tsx
@@ -1,3 +1,4 @@
+import { t } from "@/lib/i18n";
import { useEffect, useRef, useState } from "react";
import { Check, Cloud, Laptop, Loader2, Trash2 } from "lucide-react";
import { Card } from "./SettingsPrimitives";
@@ -73,7 +74,7 @@ export function ConnectedWorkspacesSettings() {
const forgetEntry = locals.find(entry => entry.id === envForget);
return <>
<p className="text-[13px] leading-relaxed text-ink-secondary">One desktop app, wherever your bots live. Switching servers does not move or replace your bots, conversations, or provider accounts.</p>
- {saved?.packaged && <Card title="Environments on this computer" subtitle="Separate setups on this computer, each with its own bots, conversations and data folder.">
+ {saved?.packaged && <Card title={t("connectedWorkspaces.localTitle")} subtitle={t("connectedWorkspaces.localSubtitle")}>
{envError && <p role="alert" className="text-[12px] text-danger">{envError}</p>}
{locals.length > 0 && <ul className="divide-y divide-hairline/40">
{locals.map((entry) => {
@@ -82,17 +83,17 @@ export function ConnectedWorkspacesSettings() {
<Laptop size={18} className="shrink-0 text-ink-secondary" />
<div className="min-w-0 flex-1"><div className="truncate text-[13px] font-medium text-ink">{entry.name}</div>
<div className="break-all text-[12px] text-ink-secondary">{entry.dataDir}
- {entry.missing && <span className="ml-2 rounded-md bg-inset px-1.5 py-0.5 text-[11px]">missing</span>}</div></div>
- {active ? <span className="flex shrink-0 items-center gap-1 text-[12px] text-ink-secondary"><Check size={13} />Current</span> :
- <button type="button" disabled={busy} aria-label={`Switch to ${entry.name}`}
+ {entry.missing && <span className="ml-2 rounded-md bg-inset px-1.5 py-0.5 text-[11px]">{t("connectedWorkspaces.missing")}</span>}</div></div>
+ {active ? <span className="flex shrink-0 items-center gap-1 text-[12px] text-ink-secondary"><Check size={13} />{t("connectedWorkspaces.current")}</span> :
+ <button type="button" disabled={busy} aria-label={t("connectedWorkspaces.switchTo", { name: entry.name })}
onClick={() => void perform(async () => {
- if (!await confirmAction(`Switch to ${entry.name}? The app restarts on that environment. Running turns stop.`)) return;
+ if (!await confirmAction(t("connectedWorkspaces.switchConfirm", { name: entry.name }))) return;
const result = await bridge.switch(entry.id);
- if (result && result.ok === false) throw new Error("Couldn't switch.");
+ if (result && result.ok === false) throw new Error(t("connectedWorkspaces.switchError"));
return true;
}, setEnvError)}
- className="rounded-md px-2 py-1.5 text-[12px] text-ink hover:bg-control disabled:opacity-50">Switch</button>}
- {!active && <button type="button" disabled={busy} aria-label={`Forget ${entry.name}`} title={`Forget ${entry.name}`}
+ className="rounded-md px-2 py-1.5 text-[12px] text-ink hover:bg-control disabled:opacity-50">{t("connectedWorkspaces.switch")}</button>}
+ {!active && <button type="button" disabled={busy} aria-label={t("connectedWorkspaces.forgetName", { name: entry.name })} title={t("connectedWorkspaces.forgetName", { name: entry.name })}
onClick={() => { setEnvForget(entry.id); setEnvPurge(false); }}
className="rounded-md p-1.5 text-ink-secondary hover:bg-control hover:text-danger disabled:opacity-50"><Trash2 size={14} /></button>}
</li>;
@@ -101,43 +102,43 @@ export function ConnectedWorkspacesSettings() {
{forgetEntry && <div className="mt-3 rounded-lg border border-hairline/40 p-3">
<label className="flex items-start gap-2 text-[12px] leading-relaxed text-ink-secondary">
<input type="checkbox" checked={envPurge} disabled={busy} className="mt-0.5" onChange={(event) => setEnvPurge(event.target.checked)} />
- Also delete this folder and everything in it ({forgetEntry.dataDir}). Otherwise the folder, its bots and conversations stay on this computer.
+ {t("connectedWorkspaces.forgetPurge", { path: forgetEntry.dataDir ?? "" })}
</label>
<div className="mt-2 flex gap-2">
<button type="button" disabled={busy} onClick={() => void perform(async () => {
const result = envPurge ? await bridge.forget(forgetEntry.id, true) : await bridge.forget(forgetEntry.id);
- if (result && result.ok === false) throw new Error("Couldn't forget the environment.");
+ if (result && result.ok === false) throw new Error(t("connectedWorkspaces.forgetError"));
setEnvForget(null);
- }, setEnvError)} className="rounded-lg px-3 py-1.5 text-[12px] font-medium text-danger hover:bg-control disabled:opacity-50">Forget</button>
- <button type="button" onClick={() => setEnvForget(null)} className="rounded-lg px-3 py-1.5 text-[12px] text-ink hover:bg-control">Cancel</button>
+ }, setEnvError)} className="rounded-lg px-3 py-1.5 text-[12px] font-medium text-danger hover:bg-control disabled:opacity-50">{t("connectedWorkspaces.forget")}</button>
+ <button type="button" onClick={() => setEnvForget(null)} className="rounded-lg px-3 py-1.5 text-[12px] text-ink hover:bg-control">{t("connectedWorkspaces.cancel")}</button>
</div>
</div>}
- <p className="mt-4 text-[13px] font-medium text-ink">New environment</p>
+ <p className="mt-4 text-[13px] font-medium text-ink">{t("connectedWorkspaces.newEnvironment")}</p>
<form className="flex flex-col gap-3 pt-2" onSubmit={(event) => {
event.preventDefault();
if (!envName.trim()) return;
void perform(async () => {
const created = await bridge.create(envName.trim(), envDir.trim() || undefined);
- if (!created?.ok) throw new Error("Couldn't create the environment.");
+ if (!created?.ok) throw new Error(t("connectedWorkspaces.createError"));
setEnvName(""); setEnvDir("");
}, setEnvError);
}}>
- <label className="flex flex-col gap-1.5 text-[12px] text-ink-secondary">Name
- <input required value={envName} disabled={busy} maxLength={60} onChange={(event) => setEnvName(event.target.value)} placeholder="My environment"
+ <label className="flex flex-col gap-1.5 text-[12px] text-ink-secondary">{t("connectedWorkspaces.name")}
+ <input required value={envName} disabled={busy} maxLength={60} onChange={(event) => setEnvName(event.target.value)} placeholder={t("connectedWorkspaces.environmentPlaceholder")}
className="w-full rounded-lg border border-hairline/40 bg-inset px-3 py-2 text-[14px] text-ink outline-none focus:border-accent/50" />
</label>
- <label className="flex flex-col gap-1.5 text-[12px] text-ink-secondary">Data folder (optional)
+ <label className="flex flex-col gap-1.5 text-[12px] text-ink-secondary">{t("connectedWorkspaces.dataFolder")}
<span className="flex gap-2">
- <input value={envDir} disabled={busy} onChange={(event) => setEnvDir(event.target.value)} placeholder="Leave empty to create one in your home folder"
+ <input value={envDir} disabled={busy} onChange={(event) => setEnvDir(event.target.value)} placeholder={t("connectedWorkspaces.defaultFolder")}
className="w-full rounded-lg border border-hairline/40 bg-inset px-3 py-2 text-[14px] text-ink outline-none focus:border-accent/50" />
<button type="button" disabled={busy} onClick={() => void perform(async () => {
const picked = await bridge.pickDir();
if (picked?.ok && picked.path) setEnvDir(picked.path);
- }, setEnvError)} className="shrink-0 rounded-lg border border-hairline/40 px-3 text-[12px] text-ink hover:bg-control disabled:opacity-50">Choose…</button>
+ }, setEnvError)} className="shrink-0 rounded-lg border border-hairline/40 px-3 text-[12px] text-ink hover:bg-control disabled:opacity-50">{t("connectedWorkspaces.choose")}</button>
</span>
</label>
<button type="submit" disabled={busy || !envName.trim()} className="flex w-fit items-center gap-2 rounded-lg bg-accent px-3 py-2 text-[13px] font-medium text-accent-ink disabled:opacity-50">
- {busy && <Loader2 size={14} className="animate-spin" />}Create
+ {busy && <Loader2 size={14} className="animate-spin" />}{t("connectedWorkspaces.create")}
</button>
</form>
</Card>}
diff --git a/src/locales/en.json b/src/locales/en.json
index 31ed5ae557..3684cb9128 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -1,4 +1,25 @@
{
+ "connectedWorkspaces.localTitle": "Environments on this computer",
+ "connectedWorkspaces.missing": "missing",
+ "connectedWorkspaces.current": "Current",
+ "connectedWorkspaces.switch": "Switch",
+ "connectedWorkspaces.forgetPurge": "Also delete this folder and everything in it ({path}). Otherwise the folder, its bots and conversations stay on this computer.",
+ "connectedWorkspaces.forget": "Forget",
+ "connectedWorkspaces.cancel": "Cancel",
+ "connectedWorkspaces.newEnvironment": "New environment",
+ "connectedWorkspaces.name": "Name",
+ "connectedWorkspaces.environmentPlaceholder": "My environment",
+ "connectedWorkspaces.dataFolder": "Data folder (optional)",
+ "connectedWorkspaces.defaultFolder": "Leave empty to create one in your home folder",
+ "connectedWorkspaces.choose": "Choose…",
+ "connectedWorkspaces.create": "Create",
+ "connectedWorkspaces.localSubtitle": "Separate setups on this computer, each with its own bots, conversations and data folder.",
+ "connectedWorkspaces.switchTo": "Switch to {name}",
+ "connectedWorkspaces.switchConfirm": "Switch to {name}? The app restarts on that environment. Running turns stop.",
+ "connectedWorkspaces.switchError": "Couldn't switch.",
+ "connectedWorkspaces.forgetName": "Forget {name}",
+ "connectedWorkspaces.forgetError": "Couldn't forget the environment.",
+ "connectedWorkspaces.createError": "Couldn't create the environment.",
"whop.description": "Products, checkout links, memberships and payments through Whop’s official integration.",
"whop.otherAppsSetup": "Whop is connected. Set up or restore the connection service to use the other apps.",
"whop.connect": "Connect Whop",
diff --git a/src/locales/zh.json b/src/locales/zh.json
index 84b6ff6518..078674d1ac 100644
--- a/src/locales/zh.json
+++ b/src/locales/zh.json
@@ -1,4 +1,25 @@
{
+ "connectedWorkspaces.localTitle": "这台电脑上的环境",
+ "connectedWorkspaces.missing": "不存在",
+ "connectedWorkspaces.current": "当前",
+ "connectedWorkspaces.switch": "切换",
+ "connectedWorkspaces.forgetPurge": "同时删除此文件夹及其中的所有内容({path})。否则,该文件夹及其中的机器人和对话将保留在这台电脑上。",
+ "connectedWorkspaces.forget": "移除",
+ "connectedWorkspaces.cancel": "取消",
+ "connectedWorkspaces.newEnvironment": "新建环境",
+ "connectedWorkspaces.name": "名称",
+ "connectedWorkspaces.environmentPlaceholder": "我的环境",
+ "connectedWorkspaces.dataFolder": "数据文件夹(可选)",
+ "connectedWorkspaces.defaultFolder": "留空将在用户主文件夹中创建",
+ "connectedWorkspaces.choose": "选择…",
+ "connectedWorkspaces.create": "创建",
+ "connectedWorkspaces.localSubtitle": "在这台电脑上创建独立环境,每个环境都有自己的机器人、会话和数据文件夹。",
+ "connectedWorkspaces.switchTo": "切换到 {name}",
+ "connectedWorkspaces.switchConfirm": "切换到 {name}?应用会重启并打开该环境,正在执行的任务将停止。",
+ "connectedWorkspaces.switchError": "无法切换环境。",
+ "connectedWorkspaces.forgetName": "移除 {name}",
+ "connectedWorkspaces.forgetError": "无法移除该环境。",
+ "connectedWorkspaces.createError": "无法创建环境。",
"highlevel.unavailable": "这里不可用。",
"postiz.description": "用 Postiz 撰写草稿、排期并发布社交媒体帖子。",
"postiz.connect": "连接 Postiz",