A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
Rust: errors, notes and labels shown to the user in the interface language
Claudee7760dff1844
diff --git a/windows/src-tauri/src/agents.rs b/windows/src-tauri/src/agents.rsindex c791d368..76c4436b 100644--- a/windows/src-tauri/src/agents.rs+++ b/windows/src-tauri/src/agents.rs@@ -231,7 +231,7 @@ impl Agent {}// Plugins are whole files (see `plugin`), never merged into JSON.(Agent::OpenCode | Agent::Amp | Agent::Hermes, _) => {- Box::new(|_| Err("This agent takes a plugin, not hook entries.".into()))+ Box::new(|_| Err(crate::i18n::t("This agent takes a plugin, not hook entries.")))}}}@@ -273,8 +273,7 @@ impl Agent {// ── Strings shown in Settings ─────────────────────────────────────────────────-const TEXT_UNTOUCHED: &str = "Coucou has not touched it.";-const TEXT_UNEXPECTED: &str = "has an unexpected type — Coucou has not touched it.";+// English keys, shown in the interface language (i18n.rs). Agent names are not translated.impl Agent {pub fn name(self) -> &'static str {@@ -292,17 +291,18 @@ impl Agent {}/// What to do once the file is written, shown with the result.- fn note(self) -> &'static str {+ fn note(self) -> String {+ use crate::i18n::t;match self {- Agent::Gemini => "Start a new Gemini CLI session to pick the hooks up.",- Agent::Antigravity => "Start a new Antigravity conversation to pick the hooks up.",- Agent::Cursor => "Restart Cursor to pick the hooks up.",- Agent::Codex => "Codex runs new hooks only once you trust them: start Codex and review them once with /hooks.",- Agent::Copilot => "Start a new Copilot CLI session to pick the hooks up.",- Agent::Muse => "Start a new Muse Code session to pick the hooks up.",- Agent::OpenCode => "Restart OpenCode to load the plugin.",- Agent::Amp => "Restart Amp to load the plugin.",- Agent::Hermes => "Turn it on once with `hermes plugins enable coucou`, then start a new Hermes session.",+ Agent::Gemini => t("Start a new Gemini CLI session to pick the hooks up."),+ Agent::Antigravity => t("Start a new Antigravity conversation to pick the hooks up."),+ Agent::Cursor => t("Restart Cursor to pick the hooks up."),+ Agent::Codex => t("Codex runs new hooks only once you trust them: start Codex and review them once with /hooks."),+ Agent::Copilot => t("Start a new Copilot CLI session to pick the hooks up."),+ Agent::Muse => t("Start a new Muse Code session to pick the hooks up."),+ Agent::OpenCode => t("Restart OpenCode to load the plugin."),+ Agent::Amp => t("Restart Amp to load the plugin."),+ Agent::Hermes => t("Turn it on once with `hermes plugins enable coucou`, then start a new Hermes session."),}}}@@ -320,11 +320,11 @@ pub struct AgentStatus {pub hook_ready: bool,/// The island can allow or deny this agent's permission requests.pub approvals: bool,- pub note: &'static str,+ pub note: String,}fn find(id: &str) -> Result<Agent, String> {- Agent::from_id(id).ok_or_else(|| format!("Unknown agent \"{id}\"."))+ Agent::from_id(id).ok_or_else(|| crate::i18n::tf("Unknown agent \"{id}\".", &[("id", id)]))}pub fn list() -> Vec<AgentStatus> {@@ -369,7 +369,7 @@ fn apply_in(agent: Agent, home: &Path, relay: &Relay, install: bool, fingerprint// ── Shared JSON helpers ───────────────────────────────────────────────────────fn unexpected(what: &str) -> String {- format!("{what} {TEXT_UNEXPECTED}")+ crate::i18n::tf("{what} has an unexpected type — Coucou has not touched it.", &[("what", what)])}/// `root[key]` as an object to edit: absent is empty, anything else is refused.@@ -550,7 +550,7 @@ fn antigravity_is_ours(group: &Value) -> bool {fn antigravity_install(root: &Value, block: &Value) -> Result<Value, String> {let mut root = root.as_object().cloned().unwrap_or_default();if root.get("coucou").is_some_and(|g| !antigravity_is_ours(g)) {- return Err(format!("A hook group named \"coucou\" that Coucou did not write is already there — {TEXT_UNTOUCHED}"));+ return Err(crate::i18n::t("A hook group named \"coucou\" that Coucou did not write is already there — Coucou has not touched it."));}root.insert("coucou".into(), block.clone());Ok(Value::Object(root))@@ -748,7 +748,7 @@ fn plugin_edit(path: PathBuf, content: String, install: bool) -> FileEdit<'statilet name = label.clone();let edit = config_file::text_edit(label, move |current| match (install, current) {(_, Some(text)) if !is_our_plugin(text) => {- Err(format!("{name} wasn't written by Coucou — {TEXT_UNTOUCHED}"))+ Err(crate::i18n::tf("{name} wasn't written by Coucou — Coucou has not touched it.", &[("name", &name.to_string())]))}(true, _) => Ok(Some(content.clone())),(false, _) => Ok(None),diff --git a/windows/src-tauri/src/chat.rs b/windows/src-tauri/src/chat.rsindex 834d5b48..d5c939cf 100644--- a/windows/src-tauri/src/chat.rs+++ b/windows/src-tauri/src/chat.rs@@ -198,13 +198,13 @@ pub async fn send(/// that provider, and only once it has a key (or, for a local server, an/// address): nothing is sent anywhere before that.pub async fn models(settings: &Settings, provider: &str) -> Result<Vec<ModelInfo>, String> {- const NO_KEY: &str = "No API key — add it in Settings.";+ let no_key = || crate::i18n::t("No API key — add it in Settings.");if provider == ANTHROPIC {- let key = secrets::get(claude::KEY).ok_or(NO_KEY)?;+ let key = secrets::get(claude::KEY).ok_or_else(no_key)?;return claude::models(&key).await;}if let Some(p) = openai_compat::provider(provider) {- let key = secrets::get(p.key).ok_or(NO_KEY)?;+ let key = secrets::get(p.key).ok_or_else(no_key)?;return openai_compat::models(p, &key).await;}if let Some(server) = local_chat::server(settings, provider) {diff --git a/windows/src-tauri/src/claude.rs b/windows/src-tauri/src/claude.rsindex 2080347a..8b47c359 100644--- a/windows/src-tauri/src/claude.rs+++ b/windows/src-tauri/src/claude.rs@@ -15,6 +15,7 @@ use reqwest::Url;use serde_json::{json, Value};use crate::chat::{self, Chat, ChatContext, ChatReply, ModelInfo};+use crate::i18n::{t, tf};use crate::{net, secrets};/// Credential store entry of the Anthropic API key.@@ -121,15 +122,16 @@ fn interpret(response: &Value) -> Result<(Vec<Value>, String), String> {let why = response.pointer("/stop_details/explanation").and_then(Value::as_str)- .unwrap_or("Claude declined this one.");- return Err(why.to_string());+ .map(str::to_string)+ .unwrap_or_else(|| t("Claude declined this one."));+ return Err(why);}let blocks = response.get("content").and_then(Value::as_array).cloned()- .ok_or("Unexpected API response.")?;- let text = response_text(&blocks).ok_or("No response text.")?;+ .ok_or_else(|| t("Unexpected API response."))?;+ let text = response_text(&blocks).ok_or_else(|| t("No response text."))?;Ok((blocks, text))}@@ -141,7 +143,7 @@ pub async fn send(query: String,context: Option<ChatContext>,) -> Result<ChatReply, String> {- let key = secrets::get(KEY).ok_or_else(|| "API key missing. Open settings.".to_string())?;+ let key = secrets::get(KEY).ok_or_else(|| t("API key missing. Open settings."))?;let endpoint = endpoint()?;let turn = chat.begin(chat::ANTHROPIC);@@ -168,7 +170,7 @@ async fn call(endpoint: &Url, key: &str, body: &Value) -> Result<Value, String>.json(body).send().await- .map_err(|e| format!("Network error: {e}"))?;+ .map_err(|e| tf("Network error: {error}", &[("error", &e.to_string())]))?;let status = response.status();if !status.is_success() {@@ -177,7 +179,7 @@ async fn call(endpoint: &Url, key: &str, body: &Value) -> Result<Value, String>return Err(format!("Claude API {status}: {}", net::error_detail(&body)));}let bytes = net::read_capped(response, net::MAX_BODY).await?;- serde_json::from_slice(&bytes).map_err(|e| format!("Bad API response: {e}"))+ serde_json::from_slice(&bytes).map_err(|e| tf("Bad API response: {error}", &[("error", &e.to_string())]))}/// The models on the user's Anthropic account, newest first, as the API lists them.@@ -189,14 +191,14 @@ pub async fn models(key: &str) -> Result<Vec<ModelInfo>, String> {.header("anthropic-version", ANTHROPIC_VERSION).send().await- .map_err(|e| format!("Network error: {e}"))?;+ .map_err(|e| tf("Network error: {error}", &[("error", &e.to_string())]))?;let status = response.status();if !status.is_success() {let body = net::read_capped(response, net::MAX_ERROR_BODY).await.unwrap_or_default();return Err(format!("Claude API {status}: {}", net::error_detail(&body)));}let bytes = net::read_capped(response, net::MAX_BODY).await?;- let json: Value = serde_json::from_slice(&bytes).map_err(|_| "Unexpected API response.".to_string())?;+ let json: Value = serde_json::from_slice(&bytes).map_err(|_| t("Unexpected API response."))?;Ok(parse_models(&json))}diff --git a/windows/src-tauri/src/config_file.rs b/windows/src-tauri/src/config_file.rsindex 25ec52b6..3dc5114d 100644--- a/windows/src-tauri/src/config_file.rs+++ b/windows/src-tauri/src/config_file.rs@@ -19,6 +19,8 @@ use std::path::{Path, PathBuf};use serde::Serialize;use serde_json::{json, Value};+use crate::i18n::{t, tf};+/// What an edit wants a file to become.pub struct Change {/// The current contents as the diff shows them.@@ -60,7 +62,7 @@ pub fn read(path: &Path) -> Result<Option<Vec<u8>>, String> {match std::fs::read(path) {Ok(bytes) => Ok(Some(bytes)),Err(err) if err.kind() == ErrorKind::NotFound => Ok(None),- Err(err) => Err(format!("Can't read {}: {err}", path.display())),+ Err(err) => Err(tf("Can't read {path}: {error}", &[("path", &path.display().to_string()), ("error", &err.to_string())])),}}@@ -75,9 +77,10 @@ pub fn parse_json(bytes: Option<&[u8]>, label: &str) -> Result<Value, String> {}match serde_json::from_slice::<Value>(text) {Ok(v) if v.is_object() => Ok(v),- Ok(_) => Err(format!("{label} isn't a JSON object — Coucou won't touch it.")),- Err(err) => Err(format!(- "{label} isn't valid JSON ({err}). Fix or move it, then try again — Coucou won't overwrite it."+ Ok(_) => Err(tf("{file} isn't a JSON object — Coucou won't touch it.", &[("file", label)])),+ Err(err) => Err(tf(+ "{file} isn't valid JSON ({error}). Fix or move it, then try again — Coucou won't overwrite it.",+ &[("file", label), ("error", &err.to_string())],)),}}@@ -116,7 +119,7 @@ pub fn text_edit<'a>(None => None,Some(b) => Some(std::str::from_utf8(b)- .map_err(|_| format!("{label} isn't UTF-8 text — Coucou won't touch it."))?,+ .map_err(|_| tf("{file} isn't UTF-8 text — Coucou won't touch it.", &[("file", &label)]))?,),};let after = change(current)?;@@ -158,8 +161,8 @@ pub fn preview(edits: &[FileEdit]) -> Result<Plan, String> {let after = change.after.clone().unwrap_or_default();let mut diff = unified_diff(&change.before, after.trim_end_matches('\n'));match (¤t, &change.after) {- (Some(_), None) => diff = format!("The file is removed.\n{diff}"),- (None, None) => diff = "No change.".into(),+ (Some(_), None) => diff = format!("{}\n{diff}", t("The file is removed.")),+ (None, None) => diff = t("No change."),_ => {}}if edits.len() > 1 {@@ -190,15 +193,15 @@ pub fn preview(edits: &[FileEdit]) -> Result<Plan, String> {pub fn apply(edits: &[FileEdit], expected: &str) -> Result<Vec<PathBuf>, String> {let wanted: Vec<&str> = expected.split(':').collect();if wanted.len() != edits.len() {- return Err("The preview is out of date. Nothing was written — review the new diff.".into());+ return Err(t("The preview is out of date. Nothing was written — review the new diff."));}let mut planned = Vec::new();for (file, want) in edits.iter().zip(wanted) {let current = read(&file.path)?;if fingerprint_of(current.as_deref()) != want {- return Err(format!(- "{} changed since the preview. Nothing was written — review the new diff.",- file.path.display()+ return Err(tf(+ "{path} changed since the preview. Nothing was written — review the new diff.",+ &[("path", &file.path.display().to_string())],));}let change = (file.edit)(current.as_deref())?;@@ -209,7 +212,12 @@ pub fn apply(edits: &[FileEdit], expected: &str) -> Result<Vec<PathBuf>, String>for (file, current, _) in &planned {if let Some(bytes) = current {let copy = back_up(&file.path, bytes)- .map_err(|e| format!("Backup of {} failed, nothing was written: {e}", file.path.display()))?;+ .map_err(|e| {+ tf(+ "Backup of {path} failed, nothing was written: {error}",+ &[("path", &file.path.display().to_string()), ("error", &e.to_string())],+ )+ })?;backups.push(copy);}}@@ -217,9 +225,13 @@ pub fn apply(edits: &[FileEdit], expected: &str) -> Result<Vec<PathBuf>, String>for (file, current, after) in planned {match after {Some(text) => replace(&file.path, text.as_bytes())- .map_err(|e| format!("Write to {} failed: {e}", file.path.display()))?,+ .map_err(|e| {+ tf("Write to {path} failed: {error}", &[("path", &file.path.display().to_string()), ("error", &e.to_string())])+ })?,None if current.is_some() => std::fs::remove_file(&file.path)- .map_err(|e| format!("Could not remove {}: {e}", file.path.display()))?,+ .map_err(|e| {+ tf("Could not remove {path}: {error}", &[("path", &file.path.display().to_string()), ("error", &e.to_string())])+ })?,None => {}}}diff --git a/windows/src-tauri/src/files.rs b/windows/src-tauri/src/files.rsindex 07cce8e6..629c4aa7 100644--- a/windows/src-tauri/src/files.rs+++ b/windows/src-tauri/src/files.rs@@ -64,12 +64,13 @@ fn take_dropped(path: &str) -> bool {pub fn ingest(source: &str) -> Result<DroppedFile, String> {if !take_dropped(source) {- return Err("Only files dropped on the island can be added.".into());+ return Err(crate::i18n::t("Only files dropped on the island can be added."));}let src = Path::new(source);- let meta = std::fs::metadata(src).map_err(|e| format!("cannot read {source}: {e}"))?;+ let meta = std::fs::metadata(src)+ .map_err(|e| crate::i18n::tf("Cannot read {path}: {error}", &[("path", source), ("error", &e.to_string())]))?;if meta.is_dir() {- return Err("Folders can't be dropped yet.".into());+ return Err(crate::i18n::t("Folders can't be dropped yet."));}let dir = inbox_dir();@@ -94,7 +95,7 @@ pub fn ingest(source: &str) -> Result<DroppedFile, String> {}}- std::fs::copy(src, &dest).map_err(|e| format!("cannot copy: {e}"))?;+ std::fs::copy(src, &dest).map_err(|e| crate::i18n::tf("Cannot copy: {error}", &[("error", &e.to_string())]))?;// CopyFileEx carries the source's timestamps across, so a file last edited// three years ago would arrive already older than the sweep window and be// deleted on the spot. The inbox ages from when *we* copied it.diff --git a/windows/src-tauri/src/hooks.rs b/windows/src-tauri/src/hooks.rsindex b1d61e11..098c5a8c 100644--- a/windows/src-tauri/src/hooks.rs+++ b/windows/src-tauri/src/hooks.rs@@ -137,7 +137,7 @@ fn merged(existing: &Value) -> Result<Value, String> {}fn unexpected(what: &str) -> String {- format!("settings.json: {what} has an unexpected type — Coucou has not touched it.")+ crate::i18n::tf("settings.json: {what} has an unexpected type — Coucou has not touched it.", &[("what", what)])}/// Settings with every Coucou entry removed, and nothing else changed.@@ -303,7 +303,7 @@ pub fn status_line_write(install: bool, fingerprint: &str) -> Result<String, Strlet saved = match (install, own.as_ref()) {(true, Some(own)) => {save_status_line_previous(own).map_err(|_| {- "could not save your current status line next to the relay; nothing was changed".to_string()+ crate::i18n::t("Could not save your current status line next to the relay; nothing was changed.")})?;true}diff --git a/windows/src-tauri/src/integrations.rs b/windows/src-tauri/src/integrations.rsindex a67e03a0..14969e48 100644--- a/windows/src-tauri/src/integrations.rs+++ b/windows/src-tauri/src/integrations.rs@@ -140,11 +140,13 @@ fn is_new(key: &'static str, id: &str) -> bool {}}+/// The card's error line, in the interface language (i18n.rs);+/// `unauthorised_hint` comes translated.fn status_error(code: u16, unauthorised_hint: &str) -> String {match code {- 401 => "Invalid API key (401)".into(),- 403 => unauthorised_hint.into(),- _ => format!("API error {code}"),+ 401 => crate::i18n::t("Invalid API key (401)"),+ 403 => unauthorised_hint.to_string(),+ _ => crate::i18n::tf("API error {code}", &[("code", &code.to_string())]),}}@@ -187,7 +189,7 @@ async fn poll_stripe(app: AppHandle) {emit(&app, IntegrationUpdate {id: "integration_stripe",data: json!({}),- error: Some(status_error(code, "Use a secret key (sk_live_… not pk_live_…)")),+ error: Some(status_error(code, &crate::i18n::t("Use a secret key (sk_live_… not pk_live_…)"))),event: None,});return;@@ -196,7 +198,7 @@ async fn poll_stripe(app: AppHandle) {emit(&app, IntegrationUpdate {id: "integration_stripe",data: json!({}),- error: Some(format!("No connection: {e}")),+ error: Some(crate::i18n::tf("No connection: {error}", &[("error", &e.to_string())])),event: None,});return;@@ -287,7 +289,7 @@ async fn poll_github(app: AppHandle) {emit(&app, IntegrationUpdate {id: "integration_github",data: json!({}),- error: Some(status_error(response.status().as_u16(), "Token lacks the needed scope")),+ error: Some(status_error(response.status().as_u16(), &crate::i18n::t("Token lacks the needed scope"))),event: None,});return;@@ -577,7 +579,7 @@ async fn poll_vercel(app: AppHandle) {emit(&app, IntegrationUpdate {id: "integration_vercel",data: json!({}),- error: Some(status_error(response.status().as_u16(), "Token lacks access")),+ error: Some(status_error(response.status().as_u16(), &crate::i18n::t("Token lacks access"))),event: None,});return;@@ -649,7 +651,7 @@ async fn poll_resend(app: AppHandle) {emit(&app, IntegrationUpdate {id: "integration_resend",data: json!({}),- error: Some(status_error(response.status().as_u16(), "Key lacks access")),+ error: Some(status_error(response.status().as_u16(), &crate::i18n::t("Key lacks access"))),event: None,});return;@@ -711,7 +713,7 @@ async fn poll_notion(app: AppHandle) {emit(&app, IntegrationUpdate {id: "integration_notion",data: json!({}),- error: Some(status_error(response.status().as_u16(), "Integration lacks access")),+ error: Some(status_error(response.status().as_u16(), &crate::i18n::t("Integration lacks access"))),event: None,});return;@@ -798,7 +800,7 @@ async fn poll_calcom(app: AppHandle) {emit(&app, IntegrationUpdate {id: "integration_calcom",data: json!({}),- error: Some(status_error(response.status().as_u16(), "Key lacks access")),+ error: Some(status_error(response.status().as_u16(), &crate::i18n::t("Key lacks access"))),event: None,});return;@@ -903,7 +905,7 @@ async fn poll_n8n(app: AppHandle) {format!("{base}/rest/executions/{id}?includeData=true"),format!("{base}/rest/executions/{id}"),];- let mut name = "Workflow".to_string();+ let mut name = crate::i18n::t("Workflow");let mut detail = None;for url in &detail_urls {let Ok(response) = http.get(url).header("X-N8N-API-KEY", &key).header("Accept", "application/json").send().await@@ -919,8 +921,8 @@ async fn poll_n8n(app: AppHandle) {.and_then(|w| w.get("name")).and_then(Value::as_str).or_else(|| json.get("name").and_then(Value::as_str))- .unwrap_or("Workflow")- .to_string();+ .map(str::to_string)+ .unwrap_or_else(|| crate::i18n::t("Workflow"));detail = n8n_detail(&json, success);break;}diff --git a/windows/src-tauri/src/island.rs b/windows/src-tauri/src/island.rsindex e2bb0a64..4793c79b 100644--- a/windows/src-tauri/src/island.rs+++ b/windows/src-tauri/src/island.rs@@ -137,7 +137,16 @@ pub fn monitor_choices(app: &AppHandle) -> Vec<MonitorChoice> {let d = describe(m);MonitorChoice {key: d.key(),- label: format!("{} — {}×{} at {},{}", d.name, d.w, d.h, d.x, d.y),+ label: crate::i18n::tf(+ "{name} — {width}×{height} at {x},{y}",+ &[+ ("name", &d.name),+ ("width", &d.w.to_string()),+ ("height", &d.h.to_string()),+ ("x", &d.x.to_string()),+ ("y", &d.y.to_string()),+ ],+ ),}}).collect()diff --git a/windows/src-tauri/src/local_chat.rs b/windows/src-tauri/src/local_chat.rsindex 07a13d9d..e2be452d 100644--- a/windows/src-tauri/src/local_chat.rs+++ b/windows/src-tauri/src/local_chat.rs@@ -20,6 +20,7 @@ use tauri::{AppHandle, Emitter};use crate::chat::{self, Chat, ChatContext, ChatReply, ModelInfo};use crate::island::WINDOW_LABEL;use crate::settings::Settings;+use crate::i18n::{t, tf};use crate::{net, secrets};/// Credential store entry of the key of the user's own OpenAI-compatible server.@@ -52,7 +53,7 @@ pub fn server(settings: &Settings, id: &str) -> Option<Server> {let (id, name, url, key) = match id {"ollama" => ("ollama", "Ollama", &settings.ollama_url, None),"lmstudio" => ("lmstudio", "LM Studio", &settings.lmstudio_url, None),- "custom" => ("custom", "OpenAI-compatible server", &settings.custom_url, secrets::get(CUSTOM_KEY)),+ "custom" => ("custom", crate::i18n::n_("OpenAI-compatible server"), &settings.custom_url, secrets::get(CUSTOM_KEY)),_ => return None,};Some(Server { id, name, url: url.clone(), key })@@ -78,12 +79,12 @@ fn bearer(key: Option<&str>) -> String {}fn unreachable(url: &Url) -> String {- format!("Cannot reach {}. Is the server running?", url.as_str().trim_end_matches('/'))+ tf("Cannot reach {url}. Is the server running?", &[("url", url.as_str().trim_end_matches('/'))])}fn base_url(server: &Server) -> Result<Url, String> {if server.url.trim().is_empty() {- return Err(format!("Connect {} in Settings → Local models first.", server.name));+ return Err(tf("Connect {name} in Settings → Local models first.", &[("name", &t(server.name))]));}net::normalise_server_url(&server.url)}@@ -117,7 +118,7 @@ pub async fn models(server: &Server) -> Result<Vec<ModelInfo>, String> {let url = base_url(server)?;let models = list(&url, server.key.as_deref()).await?;if models.is_empty() {- return Err(format!("No models yet. Download one in {} first.", server.name));+ return Err(tf("No models yet. Download one in {name} first.", &[("name", &t(server.name))]));}Ok(models.into_iter().map(|id| ModelInfo { label: id.clone(), id }).collect())}@@ -131,7 +132,7 @@ async fn list(base: &Url, key: Option<&str>) -> Result<Vec<String>, String> {.await.map_err(|_| unreachable(base))?;if matches!(response.status().as_u16(), 401 | 403) {- return Err("The server refused the key. Check it, then connect again.".into());+ return Err(t("The server refused the key. Check it, then connect again."));}if !response.status().is_success() {return Err(unreachable(base));@@ -220,7 +221,7 @@ pub async fn send() -> Result<ChatReply, String> {let base = base_url(server)?;if model.is_empty() {- return Err("Pick a model above the chat box first.".into());+ return Err(t("Pick a model above the chat box first."));}let turn = chat.begin(server.id);let user = json!({ "role": "user", "content": user_text(turn.first, context.as_ref(), &query) });@@ -231,7 +232,7 @@ pub async fn send(}).await?;if answer.is_empty() {- return Err("No response text.".into());+ return Err(t("No response text."));}let plain = chat::plain_question(turn.first, context.as_ref(), &query);chat.commit(&turn, user, json!({ "role": "assistant", "content": answer }), &plain, &answer);@@ -298,7 +299,7 @@ async fn stream(let status = reply.status();if status.as_u16() == 404 {- return Err(format!("{model} isn't installed. Pick another model above the chat box."));+ return Err(tf("{model} isn't installed. Pick another model above the chat box.", &[("model", model)]));}if !status.is_success() {let body = net::read_capped(reply, net::MAX_ERROR_BODY).await.unwrap_or_default();@@ -322,7 +323,7 @@ async fn stream(}}if pending.len() > MAX_LINE || accumulated.len() > MAX_ANSWER {- return Err("The server's answer is too large.".into());+ return Err(t("The server's answer is too large."));}if last.elapsed() >= DELTA_INTERVAL {last = Instant::now();diff --git a/windows/src-tauri/src/net.rs b/windows/src-tauri/src/net.rsindex ef31c7fd..3d3992fa 100644--- a/windows/src-tauri/src/net.rs+++ b/windows/src-tauri/src/net.rs@@ -10,6 +10,8 @@ use std::time::Duration;use reqwest::Url;+use crate::i18n::{t, tf};+/// Ceiling for a JSON answer: a chat reply or a model list.pub const MAX_BODY: usize = 8 * 1024 * 1024;/// Ceiling for an error body: only its message is shown.@@ -45,18 +47,18 @@ pub fn is_loopback_url(url: &Url) -> bool {pub fn normalise_server_url(raw: &str) -> Result<Url, String> {let raw = raw.trim();if raw.is_empty() {- return Err("Enter the server address first.".into());+ return Err(t("Enter the server address first."));}let with_scheme = if raw.contains("://") { raw.to_string() } else { format!("http://{raw}") };- let mut url = Url::parse(&with_scheme).map_err(|_| format!("Not a valid address: {raw}"))?;+ let mut url = Url::parse(&with_scheme).map_err(|_| tf("Not a valid address: {address}", &[("address", raw)]))?;if !matches!(url.scheme(), "http" | "https") {- return Err("The address must start with http:// or https://.".into());+ return Err(t("The address must start with http:// or https://."));}if !url.username().is_empty() || url.password().is_some() {- return Err("Leave the user name and password out of the address.".into());+ return Err(t("Leave the user name and password out of the address."));}if url.host_str().is_none_or(str::is_empty) {- return Err(format!("Not a valid address: {raw}"));+ return Err(tf("Not a valid address: {address}", &[("address", raw)]));}if is_loopback_url(&url) {let _ = url.set_ip_host(IpAddr::V4(Ipv4Addr::LOCALHOST));@@ -122,12 +124,12 @@ pub fn client(url: &Url, timeout: Duration) -> Result<reqwest::Client, String> {/// The body of `response`, refused past `limit` bytes.pub async fn read_capped(mut response: reqwest::Response, limit: usize) -> Result<Vec<u8>, String> {if response.content_length().is_some_and(|n| n > limit as u64) {- return Err("The server's answer is too large.".into());+ return Err(t("The server's answer is too large."));}let mut body = Vec::new();- while let Some(chunk) = response.chunk().await.map_err(|e| format!("Network error: {e}"))? {+ while let Some(chunk) = response.chunk().await.map_err(|e| tf("Network error: {error}", &[("error", &e.to_string())]))? {if body.len() + chunk.len() > limit {- return Err("The server's answer is too large.".into());+ return Err(t("The server's answer is too large."));}body.extend_from_slice(&chunk);}diff --git a/windows/src-tauri/src/openai_compat.rs b/windows/src-tauri/src/openai_compat.rsindex 02a49d96..06546733 100644--- a/windows/src-tauri/src/openai_compat.rs+++ b/windows/src-tauri/src/openai_compat.rs@@ -12,6 +12,7 @@ use reqwest::Url;use serde_json::{json, Value};use crate::chat::{self, Chat, ChatContext, ChatReply, ModelInfo};+use crate::i18n::{t, tf};use crate::{net, secrets};pub struct Provider {@@ -131,15 +132,21 @@ fn reply_text(p: &Provider, response: &Value) -> Result<String, String> {if let Some(msg) = response.pointer("/error/message").and_then(Value::as_str) {return Err(format!("{}: {msg}", p.name));}- Err("No response text.".into())+ Err(t("No response text."))}fn status_error(p: &Provider, status: u16, detail: &str) -> String {match status {- 401 | 403 => format!("{} rejected the API key ({status}). Check it in Settings.", p.name),- 402 => format!("{}: not enough credits (402). {detail}", p.name),- 404 => format!("{}: model not found (404). Pick another one above the chat box. {detail}", p.name),- 429 => format!("{} rate limit reached (429): {detail}", p.name),+ 401 | 403 => tf(+ "{name} rejected the API key ({status}). Check it in Settings.",+ &[("name", p.name), ("status", &status.to_string())],+ ),+ 402 => tf("{name}: not enough credits (402). {detail}", &[("name", p.name), ("detail", detail)]),+ 404 => tf(+ "{name}: model not found (404). Pick another one above the chat box. {detail}",+ &[("name", p.name), ("detail", detail)],+ ),+ 429 => tf("{name} rate limit reached (429): {detail}", &[("name", p.name), ("detail", detail)]),_ => format!("{} {status}: {detail}", p.name),}}@@ -152,9 +159,9 @@ pub async fn send(query: String,context: Option<ChatContext>,) -> Result<ChatReply, String> {- let key = secrets::get(p.key).ok_or_else(|| format!("{} API key missing. Add it in Settings.", p.name))?;+ let key = secrets::get(p.key).ok_or_else(|| tf("{name} API key missing. Add it in Settings.", &[("name", p.name)]))?;if model.is_empty() {- return Err(format!("Pick a {} model above the chat box.", p.name));+ return Err(tf("Pick a {name} model above the chat box.", &[("name", p.name)]));}let turn = chat.begin(p.id);let user = user_message(turn.first, context.as_ref(), &query);@@ -167,14 +174,14 @@ pub async fn send(.json(&body).send().await- .map_err(|e| format!("Network error: {e}"))?;+ .map_err(|e| tf("Network error: {error}", &[("error", &e.to_string())]))?;let status = response.status();if !status.is_success() {let body = net::read_capped(response, net::MAX_ERROR_BODY).await.unwrap_or_default();return Err(status_error(p, status.as_u16(), &net::error_detail(&body)));}let bytes = net::read_capped(response, net::MAX_BODY).await?;- let json: Value = serde_json::from_slice(&bytes).map_err(|e| format!("Bad API response: {e}"))?;+ let json: Value = serde_json::from_slice(&bytes).map_err(|e| tf("Bad API response: {error}", &[("error", &e.to_string())]))?;let text = reply_text(p, &json)?;let plain = chat::plain_question(turn.first, context.as_ref(), &query);@@ -191,14 +198,14 @@ pub async fn models(p: &Provider, key: &str) -> Result<Vec<ModelInfo>, String> {.bearer_auth(key).send().await- .map_err(|e| format!("Network error: {e}"))?;+ .map_err(|e| tf("Network error: {error}", &[("error", &e.to_string())]))?;let status = response.status();if !status.is_success() {let body = net::read_capped(response, net::MAX_ERROR_BODY).await.unwrap_or_default();return Err(status_error(p, status.as_u16(), &net::error_detail(&body)));}let bytes = net::read_capped(response, net::MAX_BODY).await?;- let json: Value = serde_json::from_slice(&bytes).map_err(|_| "Unexpected API response.".to_string())?;+ let json: Value = serde_json::from_slice(&bytes).map_err(|_| t("Unexpected API response."))?;Ok(parse_models(p, &json))}diff --git a/windows/src-tauri/src/recap.rs b/windows/src-tauri/src/recap.rsindex bedc5682..5e8af0e0 100644--- a/windows/src-tauri/src/recap.rs+++ b/windows/src-tauri/src/recap.rs@@ -651,19 +651,23 @@ fn write_unique(dir: &Path, stem: &str, bytes: &[u8]) -> std::io::Result<PathBuf/// that exists.fn save_png(dirs: &[PathBuf], data: &str, week: &str) -> Result<PathBuf, String> {if data.len() > MAX_PNG_BYTES / 3 * 4 + 64 {- return Err("The image is too large.".into());+ return Err(crate::i18n::t("The image is too large."));}- let bytes = decode_base64(data).ok_or("The image could not be read.")?;+ let bytes = decode_base64(data).ok_or_else(|| crate::i18n::t("The image could not be read."))?;if !bytes.starts_with(PNG_SIGNATURE) {- return Err("The image could not be read.".into());+ return Err(crate::i18n::t("The image could not be read."));}- let dir = dirs.iter().find(|d| d.is_dir()).ok_or("No Pictures or Downloads folder to save into.")?;+ let dir = dirs+ .iter()+ .find(|d| d.is_dir())+ .ok_or_else(|| crate::i18n::t("No Pictures or Downloads folder to save into."))?;let stem = if is_week_key(week) {format!("Coucou weekly recap {week}")} else {"Coucou weekly recap".to_string()};- write_unique(dir, &stem, &bytes).map_err(|err| format!("Could not save the image: {err}"))+ write_unique(dir, &stem, &bytes)+ .map_err(|err| crate::i18n::tf("Could not save the image: {error}", &[("error", &err.to_string())]))}// ── Tauri glue ────────────────────────────────────────────────────────────────