Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ Warnings are errors. The toolchain is `stable`, so a newer stable than
your local one can surface lints you cannot see — `rustup update stable`
before blaming CI.

## Translating protection rules

When updating the Core pin, update `src/i18n/guard.zh.json` for any
added or changed security rules. Use the guard and rule ID for a rule,
or the guard and slug for a group. The security UI, messages and native
notifications share this catalog. Core supplies the English fallback,
and prefix descriptions are rendered from the live matcher.

## Things this UI must not do

These are load-bearing and a PR that breaks one will be asked to change:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "thinkwatch-lite",
"private": true,
"description": "Desktop app for a local AI API gateway on macOS, Windows and Linux",
"version": "2026.11.20",
"version": "2026.11.22",
"type": "module",
"packageManager": "pnpm@11.13.1",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions release-notes/2026.11.22.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added Japanese, Traditional Chinese, Korean, and Spanish to the app. ThinkWatch Lite follows the system's preferred language at startup. You can also switch languages in Settings.
- The update window now shows release notes when available, with support for Markdown, wrapping, and scrolling. Chinese interfaces show the Chinese summary, and other interfaces show the English summary.
6 changes: 4 additions & 2 deletions scripts/shots/boot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
// 文案写成「这台电脑」。所以这里不 import 任何东西。

const q = new URLSearchParams(location.search);
const lang = q.get("lang") === "en" ? "en" : "zh";
const wanted = q.get("lang");
export const lang = wanted === "en" || wanted === "ja" || wanted === "zh-Hant" || wanted === "ko" || wanted === "es"
? wanted : "zh";

window.__TW_LANG__ = lang;
window.__TW_PLATFORM__ = "macos";
// `__TW_VIBRANT__` 故意不设:真应用的侧栏是系统的半透材质,由窗口服务器画,离屏拍不到。
// 不设它,侧栏按实色画,和别的平台一样
// 热启动:core 已经在跑,窗口取好首屏的数才露面,没有启动画面
(window as { __TW_WARM__?: boolean }).__TW_WARM__ = true;
document.documentElement.lang = lang === "en" ? "en" : "zh-CN";
document.documentElement.lang = lang === "zh" ? "zh-CN" : lang;

/**
* 定住的时钟:2026-09-25(周五)16:42:07,**本地时间**。
Expand Down
2 changes: 1 addition & 1 deletion scripts/shots/mock/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import REQUESTS from "../core/requests.json";
import { P } from "./params";
import { HOUR, MIN, NOW, clone, msg } from "./util";

const en = P.lang === "en";
const en = P.lang !== "zh" && P.lang !== "zh-Hant";

/** 一个类型「放宽」之后的样子:`"free" | "per-token"` 这类取值放宽成 string,结构不变 */
type Widen<T> = T extends string
Expand Down
3 changes: 2 additions & 1 deletion scripts/shots/mock/params.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// 这一张图是哪个场景、哪种语言。mock 的数据按它摆(连着远程时列表里当前的是哪一条……)
import { sceneOf } from "../scenes";
import { lang } from "../boot";

const q = new URLSearchParams(location.search);

export const P = {
scene: sceneOf(q.get("scene")),
lang: (q.get("lang") === "en" ? "en" : "zh") as "zh" | "en",
lang,
/** 打开哪一页 */
page: sceneOf(q.get("scene"))?.page ?? null,
/** 连着远程 core(`homelab`) */
Expand Down
2 changes: 1 addition & 1 deletion scripts/shots/mock/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function rng(seed: number) {
export const msg = (code: string, text: string, args: Record<string, string> = {}): Msg => ({ code, args, text });

/** 本来就是一句话的示例数据(用户起的名字、对话内容):按界面语言二选一 */
export const L = <A>(zh: A, en: A): A => (P.lang === "en" ? en : zh);
export const L = <A>(zh: A, en: A): A => (P.lang === "zh" || P.lang === "zh-Hant" ? zh : en);

export const clone = <T>(x: T): T => structuredClone(x);

Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thinkwatch-lite"
version = "2026.11.20"
version = "2026.11.22"
edition = "2024"
# **这个数决定依赖能升到哪一版。**edition 2024 的解析器只挑声明的 Rust
# 版本编得动的依赖:写 1.85 的时候,`cargo update` 一直停在旧的 time 和
Expand Down
15 changes: 10 additions & 5 deletions src-tauri/src/autostart/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ impl Autostart {
format!("路径中含有 % 时无法开机启动:{program}。请将应用移到不含 % 的目录。"),
format!(
"Launch at login does not work when the path contains %: {program}. Move the app to a directory without % in its path."
)
);
format!("路徑中含有 % 時無法開機啟動:{program}。請將應用移到不含 % 的目錄。"),
)));
}
if self.file.as_os_str().is_empty() || !self.file.is_absolute() {
return Err(io::Error::other(tr!(
"未能确定自启目录(HOME 未设置)",
"The autostart directory could not be determined (HOME is not set)"
"The autostart directory could not be determined (HOME is not set)";
"未能確定自啟目錄(HOME 未設定)",
)));
}
let dir = self.file.parent().expect("the entry is inside a directory");
Expand All @@ -94,7 +96,8 @@ impl Autostart {
e.kind(),
tr!(
format!("无法创建目录 {}:{e}", dir.display()),
format!("The directory {} could not be created: {e}", dir.display())
format!("The directory {} could not be created: {e}", dir.display());
format!("無法建立目錄 {}:{e}", dir.display()),
),
)
})?;
Expand Down Expand Up @@ -189,7 +192,8 @@ fn program(
.ok_or_else(|| {
tr!(
"未能确定应用程序的位置",
"The location of the application could not be determined"
"The location of the application could not be determined";
"未能確定應用程式的位置",
)
.to_string()
})?;
Expand All @@ -199,7 +203,8 @@ fn program(
format!(
"The application path is not valid UTF-8: {}",
p.to_string_lossy()
)
);
format!("應用程式路徑不是有效的 UTF-8:{}", p.to_string_lossy()),
)
})
}
Expand Down
9 changes: 6 additions & 3 deletions src-tauri/src/chatgpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ fn pending(id: &str, get: impl Fn(&Pending) -> Option<String>) -> Result<String,
.ok_or_else(|| {
tr!(
"这次登录已经结束,请重新发起",
"This sign-in has ended; start a new one"
"This sign-in has ended; start a new one";
"這次登入已經結束,請重新發起",
)
.to_string()
})
Expand All @@ -150,14 +151,16 @@ pub(crate) fn open_page(app: &tauri::AppHandle, url: &str) -> Result<(), String>
if !is_web_page(url) {
return Err(tr!(
format!("登录页地址不是 https 网页:{url}"),
format!("The sign-in address is not an https web page: {url}")
format!("The sign-in address is not an https web page: {url}");
format!("登入頁地址不是 https 網頁:{url}"),
)
.to_string());
}
app.opener().open_url(url, None::<&str>).map_err(|e| {
tr!(
format!("无法打开浏览器:{e}"),
format!("The browser could not be opened: {e}")
format!("The browser could not be opened: {e}");
format!("無法開啟瀏覽器:{e}"),
)
})
}
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/src/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ fn run(req: &Request) -> Vec<UninstallStep> {
format!("未能确定程序位置,注册项未清理({e})"),
format!(
"The program location could not be determined, so its registry entries were left in place ({e})"
)
);
format!("未能確定程式位置,註冊項未清理({e})"),
))),
}
// 卸载程序接着要删 twcore.exe,数据目录也要等它放手:不等它走,那个文件删不掉、
Expand Down
22 changes: 17 additions & 5 deletions src-tauri/src/clients/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,13 @@ async fn release_at(control: Option<&ControlClient>, owner: &str, path: &Path) -
// retain baseline/expected separately so a later explicit adoption can clean up.
save_at(path, &j)?;
if let (Some(expected), Some(_)) = (&j.expected, &j.baseline) {
let control = control
.ok_or_else(|| failed(tr!("本机网关不可用", "The local gateway is unavailable")))?;
let control = control.ok_or_else(|| {
failed(tr!(
"本机网关不可用",
"The local gateway is unavailable";
"本機閘道器不可用",
))
})?;
let ov = control
.call::<ep::Overview>(&[], &())
.await
Expand Down Expand Up @@ -651,9 +656,16 @@ pub fn watch(handle: &tauri::AppHandle, notices: std::sync::Arc<crate::notices::
if !ok {
active.insert(key.clone());
notices.ingest(Signal::raised(key, Level::Warning,
tr!("WSL 客户端无法连接网关", "WSL Gateway Unavailable"))
.body(tr!(format!("WSL · {distro} 的网关地址或监听已不可达。原配置已保留,请到客户端页检查并确认重新接管。"),
format!("The managed gateway for WSL · {distro} is unavailable. Configuration is preserved. Review the listener and reconnect from Clients to apply any address changes.")))
tr!(
"WSL 客户端无法连接网关",
"WSL Gateway Unavailable";
"WSL 用戶端無法連線閘道器",
))
.body(tr!(
format!("WSL · {distro} 的网关地址或监听已不可达。原配置已保留,请到客户端页检查并确认重新接管。"),
format!("The managed gateway for WSL · {distro} is unavailable. Configuration is preserved. Review the listener and reconnect from Clients to apply any address changes.");
format!("WSL · {distro} 的閘道器地址或監聽已不可達。原配置已保留,請到用戶端頁檢查並確認重新接管。"),
))
.view("clients"), crate::notices::now_ms());
}
}
Expand Down
15 changes: 10 additions & 5 deletions src-tauri/src/clients/reveal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ pub fn reveal(path: &str) -> Result<(), String> {
} else {
Err(tr!(
format!("无法在访达中显示 {path}"),
format!("{path} could not be shown in Finder")
format!("{path} could not be shown in Finder");
format!("無法在訪達中顯示 {path}"),
)
.to_string())
}
Expand All @@ -41,7 +42,8 @@ pub fn reveal(path: &str) -> Result<(), String> {
.map_err(|e| {
tr!(
format!("无法在文件资源管理器中显示 {path}:{e}"),
format!("{path} could not be shown in File Explorer: {e}")
format!("{path} could not be shown in File Explorer: {e}");
format!("無法在檔案資源管理器中顯示 {path}:{e}"),
)
.to_string()
})
Expand Down Expand Up @@ -73,7 +75,8 @@ fn absolute(path: &str) -> Result<(), String> {
} else {
Err(tr!(
format!("配置文件的路径不是绝对路径:{path}"),
format!("The configuration file path is not absolute: {path}")
format!("The configuration file path is not absolute: {path}");
format!("配置檔案的路徑不是絕對路徑:{path}"),
)
.to_string())
}
Expand Down Expand Up @@ -109,7 +112,8 @@ pub fn reveal(path: &str) -> Result<(), String> {
.map_err(|e| {
tr!(
format!("无法在文件管理器中显示 {path}:{e}"),
format!("{path} could not be shown in the file manager: {e}")
format!("{path} could not be shown in the file manager: {e}");
format!("無法在檔案管理器中顯示 {path}:{e}"),
)
.to_string()
})
Expand All @@ -119,7 +123,8 @@ pub fn reveal(path: &str) -> Result<(), String> {
pub fn reveal(path: &str) -> Result<(), String> {
Err(tr!(
format!("这个平台上还不能打开文件管理器:{path}"),
format!("Opening a file manager is not supported on this platform yet: {path}")
format!("Opening a file manager is not supported on this platform yet: {path}");
format!("這個平臺上還不能開啟檔案管理器:{path}"),
)
.to_string())
}
22 changes: 16 additions & 6 deletions src-tauri/src/connection/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,30 @@ impl std::fmt::Display for ConnectError {
ConnectError::Unreachable { addr } => {
tr!(
format!("无法连接到 {addr}"),
format!("Cannot connect to {addr}")
format!("Cannot connect to {addr}");
format!("無法連線到 {addr}"),
)
}
ConnectError::Closed { addr } => tr!(
format!("{addr} 关闭了连接"),
format!("{addr} closed the connection")
format!("{addr} closed the connection");
format!("{addr} 關閉了連線"),
),
ConnectError::WrongKey => tr!("密钥不正确", "The key is not correct").into(),
ConnectError::WrongKey => tr!(
"密钥不正确",
"The key is not correct";
"金鑰不正確",
)
.into(),
ConnectError::VersionMismatch { ours, theirs } => tr!(
format!("版本不一致:服务器 core {theirs},本应用需要 {ours}"),
format!("Version mismatch: the server runs core {theirs}; this app needs {ours}")
format!("Version mismatch: the server runs core {theirs}; this app needs {ours}");
format!("版本不一致:伺服器 core {theirs},本應用需要 {ours}"),
),
ConnectError::Timeout { addr } => tr!(
format!("连接 {addr} 超时"),
format!("Connecting to {addr} timed out")
format!("Connecting to {addr} timed out");
format!("連線 {addr} 超時"),
),
};
f.write_str(&s)
Expand Down Expand Up @@ -232,7 +241,8 @@ fn link_error(e: tw_link::LinkError, addr: &str) -> ConnectError {
let with_proto = |v: &str, p: u32| -> String {
tr!(
format!("{v}(控制面协议 {p})"),
format!("{v} (control protocol {p})")
format!("{v} (control protocol {p})");
format!("{v}(控制面協議 {p})"),
)
};
if peer_version == REQUIRED_CORE {
Expand Down
27 changes: 23 additions & 4 deletions src-tauri/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,11 @@ pub fn delete_connection(app: tauri::AppHandle, id: String) -> Out<ConnView> {
if id == LOCAL || st.link.current().id() == id {
return Err(CmdError::plain(tr!(
"当前连接不能删除,请先切换到其他连接。",
"The current connection cannot be deleted. Switch to another connection first."
"The current connection cannot be deleted. Switch to another connection first.",
"現在の接続は削除できません。先に別の接続に切り替えてください。";
"當前連線不能刪除,請先切換到其他連線。",
"The current connection cannot be deleted. Switch to another connection first.",
"La conexión actual no se puede borrar. Cambiar a otra conexión primero.",
)));
}
store::update(&data_dir(), |c| {
Expand Down Expand Up @@ -799,14 +803,22 @@ pub fn retry_connection(state: tauri::State<'_, AppState>) {
fn saving(e: anyhow::Error) -> CmdError {
CmdError::plain(tr!(
format!("无法保存连接列表:{e:#}"),
format!("The connection list could not be saved: {e:#}")
format!("The connection list could not be saved: {e:#}"),
format!("接続一覧を保存できませんでした:{e:#}");
format!("無法儲存連線列表:{e:#}"),
format!("The connection list could not be saved: {e:#}"),
format!("La lista de conexiones no se pudo guardar: {e:#}"),
))
}

fn key_error(e: &anyhow::Error) -> CmdError {
CmdError::plain(tr!(
format!("无法读写保存的密钥:{e:#}"),
format!("The saved key could not be read or written: {e:#}")
format!("The saved key could not be read or written: {e:#}"),
format!("保存されたキーを読み書きできませんでした:{e:#}");
format!("無法讀寫儲存的金鑰:{e:#}"),
format!("The saved key could not be read or written: {e:#}"),
format!("La llave guardada no se pudo leer ni escribir: {e:#}"),
))
}

Expand All @@ -822,7 +834,14 @@ pub fn show_picker(app: &tauri::AppHandle, why: launch::Why) -> tauri::Result<()
launch::Why::Unfinished => "unfinished",
};
let b = tauri::WebviewWindowBuilder::new(app, PICKER_WINDOW, tauri::WebviewUrl::default())
.title(tr!("选择连接", "Choose a Connection"))
.title(tr!(
"选择连接",
"Choose a Connection",
"接続を選択";
"選擇連線",
"연결 선택",
"Elegir una conexión",
))
.initialization_script(format!(
"{} window.__TW_PICK__ = {:?};",
crate::i18n::init_script(),
Expand Down
18 changes: 17 additions & 1 deletion src-tauri/src/connection/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,23 @@ pub fn local_name() -> &'static str {
"This Mac"
} else {
"This computer"
}
},
if cfg!(target_os = "macos") {
"この Mac"
} else {
"この端末"
};
"本機",
if cfg!(target_os = "macos") {
"이 Mac"
} else {
"이 컴퓨터"
},
if cfg!(target_os = "macos") {
"Este Mac"
} else {
"Este equipo"
},
)
}

Expand Down
Loading
Loading