#!/usr/bin/env python3
"""One-shot: merge the settings-modal `settings.*` strings into the
15 canonical op-i18n locale tables.

The agent-settings modal strings used to live in a hand-maintained
EN/ZH table (`agent_settings_i18n.rs`). They are now sunk into the
canonical op-i18n tables so every one of the 15 locales is covered.

`settings.title` is intentionally NOT inserted: it already exists in
op-i18n; re-adding it would create a duplicate match arm.

Idempotent: skips a file that already carries `settings.tab.agents`.
"""

import os
import re

I18N_DIR = os.path.join(os.path.dirname(__file__), "..", "crates", "op-i18n", "src", "i18n")

# Ordered key list — keeps the emitted block stable across runs.
KEYS = [
    "settings.tab.agents", "settings.tab.mcp", "settings.tab.images", "settings.tab.system",
    "settings.agents.builtin", "settings.agents.builtinSubtitle", "settings.agents.builtinEmpty",
    "settings.agents.addProvider", "settings.agents.acp", "settings.agents.acpSubtitle",
    "settings.agents.acpEmpty", "settings.agents.addAcp", "settings.agents.title",
    "settings.agents.connect", "settings.agents.disconnect", "settings.agents.claudeHint",
    "settings.mcp.server", "settings.mcp.running", "settings.mcp.stopped", "settings.mcp.port",
    "settings.mcp.start", "settings.mcp.stop", "settings.mcp.terminalIntegrations",
    "settings.mcp.terminalSubtitle1", "settings.mcp.terminalSubtitle2",
    "settings.images.search", "settings.images.ready", "settings.images.notConfigured",
    "settings.images.advanced", "settings.images.oauthLabel", "settings.images.clientId",
    "settings.images.clientSecret", "settings.images.clientIdPlaceholder",
    "settings.images.clientSecretPlaceholder", "settings.images.registerLink",
    "settings.images.test", "settings.images.generation", "settings.images.add",
    "settings.images.empty", "settings.provider.claudeCode", "settings.provider.codexCli",
    "settings.provider.openCode", "settings.provider.githubCopilot", "settings.provider.geminiCli",
    "settings.system.title", "settings.system.autoUpdate", "settings.system.upToDate",
    "settings.system.upToDateDescription", "settings.system.checking",
    "settings.system.checkingDescription", "settings.system.updateAvailable",
    "settings.system.updateAvailableDescription", "settings.system.idle",
    "settings.system.idleDescription", "settings.system.errorStatus",
    "settings.system.errorDescription", "settings.system.currentVersion",
]

EN = {
    "settings.tab.agents": "Agents",
    "settings.tab.mcp": "MCP",
    "settings.tab.images": "Images",
    "settings.tab.system": "System",
    "settings.agents.builtin": "Built-in providers",
    "settings.agents.builtinSubtitle": "Configure API keys directly — no CLI tools needed.",
    "settings.agents.builtinEmpty": "No built-in providers configured.",
    "settings.agents.addProvider": "+ Add provider",
    "settings.agents.acp": "ACP Agent",
    "settings.agents.acpSubtitle": "Connect external ACP-compatible Agents.",
    "settings.agents.acpEmpty": "No ACP Agents configured.",
    "settings.agents.addAcp": "+ Add Agent",
    "settings.agents.title": "Agents",
    "settings.agents.connect": "Connect",
    "settings.agents.disconnect": "Disconnect",
    "settings.agents.claudeHint": "You can set additional environment variables in ~/.claude/settings.json.",
    "settings.mcp.server": "MCP Server",
    "settings.mcp.running": "Running",
    "settings.mcp.stopped": "Stopped",
    "settings.mcp.port": "Port",
    "settings.mcp.start": "Start",
    "settings.mcp.stop": "Stop",
    "settings.mcp.terminalIntegrations": "Terminal MCP integrations",
    "settings.mcp.terminalSubtitle1": "MCP integrations take effect after restarting the terminal.",
    "settings.mcp.terminalSubtitle2": "After upgrading OpenPencil, please reinstall MCP integrations for compatibility.",
    "settings.images.search": "Image Search",
    "settings.images.ready": "Ready",
    "settings.images.notConfigured": "Not configured",
    "settings.images.advanced": "Advanced",
    "settings.images.oauthLabel": "Openverse OAuth (optional, for higher rate limits)",
    "settings.images.clientId": "Client ID",
    "settings.images.clientSecret": "Client Secret",
    "settings.images.clientIdPlaceholder": "your-client-id",
    "settings.images.clientSecretPlaceholder": "your-client-secret",
    "settings.images.registerLink": "Register at Openverse",
    "settings.images.test": "Test",
    "settings.images.generation": "Image Generation",
    "settings.images.add": "+ Add",
    "settings.images.empty": 'No configurations yet. Click "Add" to create one.',
    "settings.provider.claudeCode": "Claude model",
    "settings.provider.codexCli": "OpenAI models",
    "settings.provider.openCode": "75+ LLM providers",
    "settings.provider.githubCopilot": "GitHub Copilot models",
    "settings.provider.geminiCli": "Google Gemini models",
    "settings.system.title": "System",
    "settings.system.autoUpdate": "Auto-update",
    "settings.system.upToDate": "Up to date",
    "settings.system.upToDateDescription": "Running the latest published release.",
    "settings.system.checking": "Checking…",
    "settings.system.checkingDescription": "Contacting the release server for the latest version.",
    "settings.system.updateAvailable": "Update available",
    "settings.system.updateAvailableDescription": "Use “Check for Updates” in the menu to open the download page.",
    "settings.system.idle": "Not checked yet",
    "settings.system.idleDescription": "An update check runs automatically shortly after launch.",
    "settings.system.errorStatus": "Check failed",
    "settings.system.errorDescription": "Couldn't reach the release server — check your connection.",
    "settings.system.currentVersion": "Current version",
}

ZH_CN = {
    "settings.tab.system": "系统",
    "settings.agents.builtin": "内置服务商",
    "settings.agents.builtinSubtitle": "直接配置 API 密钥 — 无需 CLI 工具。",
    "settings.agents.builtinEmpty": "尚未配置内置服务商。",
    "settings.agents.addProvider": "+ 添加服务商",
    "settings.agents.acpSubtitle": "连接外部 ACP 兼容的 Agent。",
    "settings.agents.acpEmpty": "尚未配置 ACP Agent。",
    "settings.agents.addAcp": "+ 添加 Agent",
    "settings.agents.connect": "连接",
    "settings.agents.disconnect": "断开连接",
    "settings.agents.claudeHint": "你可以在 ~/.claude/settings.json 中设置额外的环境变量。",
    "settings.mcp.server": "MCP 服务器",
    "settings.mcp.running": "运行中",
    "settings.mcp.stopped": "已停止",
    "settings.mcp.port": "端口",
    "settings.mcp.start": "启动",
    "settings.mcp.stop": "停止",
    "settings.mcp.terminalIntegrations": "终端中的 MCP 集成",
    "settings.mcp.terminalSubtitle1": "MCP 集成将在重启终端后生效。",
    "settings.mcp.terminalSubtitle2": "升级 OpenPencil 版本后，请重新安装 MCP 集成以确保兼容性。",
    "settings.images.search": "图片搜索",
    "settings.images.ready": "已就绪",
    "settings.images.notConfigured": "尚未配置",
    "settings.images.advanced": "高级",
    "settings.images.oauthLabel": "Openverse OAuth（可选，用于提升速率限制）",
    "settings.images.clientId": "客户端 ID",
    "settings.images.clientSecret": "客户端密钥",
    "settings.images.registerLink": "在 Openverse 注册",
    "settings.images.test": "测试",
    "settings.images.generation": "图片生成",
    "settings.images.add": "+ 添加",
    "settings.images.empty": "尚无配置。点击“添加”创建一个。",
    "settings.provider.claudeCode": "Claude 模型",
    "settings.provider.codexCli": "OpenAI 模型",
    "settings.provider.openCode": "75+ LLM 提供商",
    "settings.provider.githubCopilot": "GitHub Copilot 模型",
    "settings.provider.geminiCli": "Google Gemini 模型",
    "settings.system.title": "系统",
    "settings.system.autoUpdate": "自动更新",
    "settings.system.upToDate": "已是最新",
    "settings.system.upToDateDescription": "当前已是最新发布版本。",
    "settings.system.checking": "检查中…",
    "settings.system.checkingDescription": "正在向发布服务器查询最新版本。",
    "settings.system.updateAvailable": "有可用更新",
    "settings.system.updateAvailableDescription": "使用菜单中的“检查更新”打开下载页面。",
    "settings.system.idle": "尚未检查",
    "settings.system.idleDescription": "启动后将自动检查更新。",
    "settings.system.errorStatus": "检查失败",
    "settings.system.errorDescription": "无法连接发布服务器，请检查网络连接。",
    "settings.system.currentVersion": "当前版本",
}

ZH_TW = {
    "settings.tab.system": "系統",
    "settings.agents.builtin": "內建服務商",
    "settings.agents.builtinSubtitle": "直接設定 API 金鑰 — 無需 CLI 工具。",
    "settings.agents.builtinEmpty": "尚未設定內建服務商。",
    "settings.agents.addProvider": "+ 新增服務商",
    "settings.agents.acpSubtitle": "連接外部 ACP 相容的 Agent。",
    "settings.agents.acpEmpty": "尚未設定 ACP Agent。",
    "settings.agents.addAcp": "+ 新增 Agent",
    "settings.agents.connect": "連接",
    "settings.agents.disconnect": "中斷連線",
    "settings.agents.claudeHint": "你可以在 ~/.claude/settings.json 中設定額外的環境變數。",
    "settings.mcp.server": "MCP 伺服器",
    "settings.mcp.running": "執行中",
    "settings.mcp.stopped": "已停止",
    "settings.mcp.port": "連接埠",
    "settings.mcp.start": "啟動",
    "settings.mcp.stop": "停止",
    "settings.mcp.terminalIntegrations": "終端機中的 MCP 整合",
    "settings.mcp.terminalSubtitle1": "MCP 整合將在重新啟動終端機後生效。",
    "settings.mcp.terminalSubtitle2": "升級 OpenPencil 版本後，請重新安裝 MCP 整合以確保相容性。",
    "settings.images.search": "圖片搜尋",
    "settings.images.ready": "已就緒",
    "settings.images.notConfigured": "尚未設定",
    "settings.images.advanced": "進階",
    "settings.images.oauthLabel": "Openverse OAuth（選用，用於提升速率限制）",
    "settings.images.clientId": "用戶端 ID",
    "settings.images.clientSecret": "用戶端密鑰",
    "settings.images.registerLink": "在 Openverse 註冊",
    "settings.images.test": "測試",
    "settings.images.generation": "圖片生成",
    "settings.images.add": "+ 新增",
    "settings.images.empty": "尚無設定。點擊「新增」建立一個。",
    "settings.provider.claudeCode": "Claude 模型",
    "settings.provider.codexCli": "OpenAI 模型",
    "settings.provider.openCode": "75+ LLM 供應商",
    "settings.provider.githubCopilot": "GitHub Copilot 模型",
    "settings.provider.geminiCli": "Google Gemini 模型",
    "settings.system.title": "系統",
    "settings.system.autoUpdate": "自動更新",
    "settings.system.upToDate": "已是最新",
    "settings.system.upToDateDescription": "目前已是最新發行版本。",
    "settings.system.checking": "檢查中…",
    "settings.system.checkingDescription": "正在向發行伺服器查詢最新版本。",
    "settings.system.updateAvailable": "有可用更新",
    "settings.system.updateAvailableDescription": "使用選單中的「檢查更新」開啟下載頁面。",
    "settings.system.idle": "尚未檢查",
    "settings.system.idleDescription": "啟動後將自動檢查更新。",
    "settings.system.errorStatus": "檢查失敗",
    "settings.system.errorDescription": "無法連線發行伺服器，請檢查網路連線。",
    "settings.system.currentVersion": "目前版本",
}

JA = {
    "settings.tab.images": "画像",
    "settings.tab.system": "システム",
    "settings.agents.builtin": "組み込みプロバイダー",
    "settings.agents.builtinSubtitle": "API キーを直接設定 — CLI ツールは不要です。",
    "settings.agents.builtinEmpty": "組み込みプロバイダーが設定されていません。",
    "settings.agents.addProvider": "+ プロバイダーを追加",
    "settings.agents.acp": "ACP エージェント",
    "settings.agents.acpSubtitle": "外部の ACP 対応エージェントに接続します。",
    "settings.agents.acpEmpty": "ACP エージェントが設定されていません。",
    "settings.agents.addAcp": "+ エージェントを追加",
    "settings.agents.connect": "接続",
    "settings.agents.disconnect": "切断",
    "settings.agents.claudeHint": "~/.claude/settings.json で追加の環境変数を設定できます。",
    "settings.mcp.server": "MCP サーバー",
    "settings.mcp.running": "実行中",
    "settings.mcp.stopped": "停止",
    "settings.mcp.port": "ポート",
    "settings.mcp.start": "開始",
    "settings.mcp.stop": "停止",
    "settings.mcp.terminalIntegrations": "ターミナルの MCP 連携",
    "settings.mcp.terminalSubtitle1": "MCP 連携はターミナルの再起動後に有効になります。",
    "settings.mcp.terminalSubtitle2": "OpenPencil をアップグレードした後は、互換性のため MCP 連携を再インストールしてください。",
    "settings.images.search": "画像検索",
    "settings.images.ready": "準備完了",
    "settings.images.notConfigured": "未設定",
    "settings.images.advanced": "詳細設定",
    "settings.images.oauthLabel": "Openverse OAuth（任意、レート制限の緩和用）",
    "settings.images.clientId": "クライアント ID",
    "settings.images.clientSecret": "クライアントシークレット",
    "settings.images.registerLink": "Openverse で登録",
    "settings.images.test": "テスト",
    "settings.images.generation": "画像生成",
    "settings.images.add": "+ 追加",
    "settings.images.empty": "設定がまだありません。「追加」をクリックして作成してください。",
    "settings.provider.claudeCode": "Claude モデル",
    "settings.provider.codexCli": "OpenAI モデル",
    "settings.provider.openCode": "75+ の LLM プロバイダー",
    "settings.provider.githubCopilot": "GitHub Copilot モデル",
    "settings.provider.geminiCli": "Google Gemini モデル",
    "settings.system.title": "システム",
    "settings.system.autoUpdate": "自動更新",
    "settings.system.upToDate": "最新です",
    "settings.system.upToDateDescription": "最新の公開リリースを使用しています。",
    "settings.system.checking": "確認中…",
    "settings.system.checkingDescription": "最新バージョンをリリースサーバーに問い合わせています。",
    "settings.system.updateAvailable": "更新があります",
    "settings.system.updateAvailableDescription": "メニューの「更新を確認」からダウンロードページを開きます。",
    "settings.system.idle": "未確認",
    "settings.system.idleDescription": "起動後まもなく更新が自動的に確認されます。",
    "settings.system.errorStatus": "確認に失敗",
    "settings.system.errorDescription": "リリースサーバーに接続できません。接続を確認してください。",
    "settings.system.currentVersion": "現在のバージョン",
}

KO = {
    "settings.tab.images": "이미지",
    "settings.tab.system": "시스템",
    "settings.agents.builtin": "내장 제공자",
    "settings.agents.builtinSubtitle": "API 키를 직접 구성 — CLI 도구가 필요 없습니다.",
    "settings.agents.builtinEmpty": "구성된 내장 제공자가 없습니다.",
    "settings.agents.addProvider": "+ 제공자 추가",
    "settings.agents.acp": "ACP 에이전트",
    "settings.agents.acpSubtitle": "외부 ACP 호환 에이전트를 연결합니다.",
    "settings.agents.acpEmpty": "구성된 ACP 에이전트가 없습니다.",
    "settings.agents.addAcp": "+ 에이전트 추가",
    "settings.agents.connect": "연결",
    "settings.agents.disconnect": "연결 해제",
    "settings.agents.claudeHint": "~/.claude/settings.json에서 추가 환경 변수를 설정할 수 있습니다.",
    "settings.mcp.server": "MCP 서버",
    "settings.mcp.running": "실행 중",
    "settings.mcp.stopped": "중지됨",
    "settings.mcp.port": "포트",
    "settings.mcp.start": "시작",
    "settings.mcp.stop": "중지",
    "settings.mcp.terminalIntegrations": "터미널 MCP 통합",
    "settings.mcp.terminalSubtitle1": "MCP 통합은 터미널을 다시 시작한 후 적용됩니다.",
    "settings.mcp.terminalSubtitle2": "OpenPencil 업그레이드 후 호환성을 위해 MCP 통합을 다시 설치하세요.",
    "settings.images.search": "이미지 검색",
    "settings.images.ready": "준비됨",
    "settings.images.notConfigured": "구성되지 않음",
    "settings.images.advanced": "고급",
    "settings.images.oauthLabel": "Openverse OAuth(선택 사항, 더 높은 속도 제한용)",
    "settings.images.clientId": "클라이언트 ID",
    "settings.images.clientSecret": "클라이언트 시크릿",
    "settings.images.registerLink": "Openverse에서 등록",
    "settings.images.test": "테스트",
    "settings.images.generation": "이미지 생성",
    "settings.images.add": "+ 추가",
    "settings.images.empty": "아직 구성이 없습니다. “추가”를 클릭하여 만드세요.",
    "settings.provider.claudeCode": "Claude 모델",
    "settings.provider.codexCli": "OpenAI 모델",
    "settings.provider.openCode": "75개 이상의 LLM 제공자",
    "settings.provider.githubCopilot": "GitHub Copilot 모델",
    "settings.provider.geminiCli": "Google Gemini 모델",
    "settings.system.title": "시스템",
    "settings.system.autoUpdate": "자동 업데이트",
    "settings.system.upToDate": "최신 상태",
    "settings.system.upToDateDescription": "최신 배포 릴리스를 실행 중입니다.",
    "settings.system.checking": "확인 중…",
    "settings.system.checkingDescription": "릴리스 서버에 최신 버전을 요청하는 중입니다.",
    "settings.system.updateAvailable": "업데이트 사용 가능",
    "settings.system.updateAvailableDescription": "메뉴의 “업데이트 확인”으로 다운로드 페이지를 엽니다.",
    "settings.system.idle": "아직 확인하지 않음",
    "settings.system.idleDescription": "시작 직후 업데이트 확인이 자동으로 실행됩니다.",
    "settings.system.errorStatus": "확인 실패",
    "settings.system.errorDescription": "릴리스 서버에 연결할 수 없습니다. 연결을 확인하세요.",
    "settings.system.currentVersion": "현재 버전",
}

FR = {
    "settings.tab.system": "Système",
    "settings.agents.builtin": "Fournisseurs intégrés",
    "settings.agents.builtinSubtitle": "Configurez les clés API directement — aucun outil CLI requis.",
    "settings.agents.builtinEmpty": "Aucun fournisseur intégré configuré.",
    "settings.agents.addProvider": "+ Ajouter un fournisseur",
    "settings.agents.acp": "Agent ACP",
    "settings.agents.acpSubtitle": "Connectez des agents externes compatibles ACP.",
    "settings.agents.acpEmpty": "Aucun agent ACP configuré.",
    "settings.agents.addAcp": "+ Ajouter un agent",
    "settings.agents.connect": "Connecter",
    "settings.agents.disconnect": "Déconnecter",
    "settings.agents.claudeHint": "Vous pouvez définir des variables d'environnement supplémentaires dans ~/.claude/settings.json.",
    "settings.mcp.server": "Serveur MCP",
    "settings.mcp.running": "En cours d'exécution",
    "settings.mcp.stopped": "Arrêté",
    "settings.mcp.port": "Port",
    "settings.mcp.start": "Démarrer",
    "settings.mcp.stop": "Arrêter",
    "settings.mcp.terminalIntegrations": "Intégrations MCP du terminal",
    "settings.mcp.terminalSubtitle1": "Les intégrations MCP prennent effet après le redémarrage du terminal.",
    "settings.mcp.terminalSubtitle2": "Après la mise à niveau d'OpenPencil, veuillez réinstaller les intégrations MCP pour la compatibilité.",
    "settings.images.search": "Recherche d'images",
    "settings.images.ready": "Prêt",
    "settings.images.notConfigured": "Non configuré",
    "settings.images.advanced": "Avancé",
    "settings.images.oauthLabel": "Openverse OAuth (facultatif, pour des limites de débit plus élevées)",
    "settings.images.clientId": "ID client",
    "settings.images.clientSecret": "Secret client",
    "settings.images.registerLink": "S'inscrire sur Openverse",
    "settings.images.test": "Tester",
    "settings.images.generation": "Génération d'images",
    "settings.images.add": "+ Ajouter",
    "settings.images.empty": "Aucune configuration pour l'instant. Cliquez sur « Ajouter » pour en créer une.",
    "settings.provider.claudeCode": "Modèle Claude",
    "settings.provider.codexCli": "Modèles OpenAI",
    "settings.provider.openCode": "Plus de 75 fournisseurs de LLM",
    "settings.provider.githubCopilot": "Modèles GitHub Copilot",
    "settings.provider.geminiCli": "Modèles Google Gemini",
    "settings.system.title": "Système",
    "settings.system.autoUpdate": "Mise à jour automatique",
    "settings.system.upToDate": "À jour",
    "settings.system.upToDateDescription": "Vous utilisez la dernière version publiée.",
    "settings.system.checking": "Vérification…",
    "settings.system.checkingDescription": "Contact du serveur de versions pour la dernière version.",
    "settings.system.updateAvailable": "Mise à jour disponible",
    "settings.system.updateAvailableDescription": "Utilisez « Rechercher les mises à jour » dans le menu pour ouvrir la page de téléchargement.",
    "settings.system.idle": "Pas encore vérifié",
    "settings.system.idleDescription": "Une vérification des mises à jour s'exécute automatiquement peu après le lancement.",
    "settings.system.errorStatus": "Échec de la vérification",
    "settings.system.errorDescription": "Impossible de joindre le serveur de versions — vérifiez votre connexion.",
    "settings.system.currentVersion": "Version actuelle",
}

ES = {
    "settings.tab.images": "Imágenes",
    "settings.tab.system": "Sistema",
    "settings.agents.builtin": "Proveedores integrados",
    "settings.agents.builtinSubtitle": "Configura las claves de API directamente — no se necesitan herramientas CLI.",
    "settings.agents.builtinEmpty": "No hay proveedores integrados configurados.",
    "settings.agents.addProvider": "+ Añadir proveedor",
    "settings.agents.acp": "Agente ACP",
    "settings.agents.acpSubtitle": "Conecta agentes externos compatibles con ACP.",
    "settings.agents.acpEmpty": "No hay agentes ACP configurados.",
    "settings.agents.addAcp": "+ Añadir agente",
    "settings.agents.connect": "Conectar",
    "settings.agents.disconnect": "Desconectar",
    "settings.agents.claudeHint": "Puedes definir variables de entorno adicionales en ~/.claude/settings.json.",
    "settings.mcp.server": "Servidor MCP",
    "settings.mcp.running": "En ejecución",
    "settings.mcp.stopped": "Detenido",
    "settings.mcp.port": "Puerto",
    "settings.mcp.start": "Iniciar",
    "settings.mcp.stop": "Detener",
    "settings.mcp.terminalIntegrations": "Integraciones MCP de terminal",
    "settings.mcp.terminalSubtitle1": "Las integraciones MCP surten efecto tras reiniciar la terminal.",
    "settings.mcp.terminalSubtitle2": "Después de actualizar OpenPencil, reinstala las integraciones MCP para garantizar la compatibilidad.",
    "settings.images.search": "Búsqueda de imágenes",
    "settings.images.ready": "Listo",
    "settings.images.notConfigured": "Sin configurar",
    "settings.images.advanced": "Avanzado",
    "settings.images.oauthLabel": "Openverse OAuth (opcional, para límites de tasa más altos)",
    "settings.images.clientId": "ID de cliente",
    "settings.images.clientSecret": "Secreto de cliente",
    "settings.images.registerLink": "Registrarse en Openverse",
    "settings.images.test": "Probar",
    "settings.images.generation": "Generación de imágenes",
    "settings.images.add": "+ Añadir",
    "settings.images.empty": "Aún no hay configuraciones. Haz clic en « Añadir » para crear una.",
    "settings.provider.claudeCode": "Modelo Claude",
    "settings.provider.codexCli": "Modelos OpenAI",
    "settings.provider.openCode": "Más de 75 proveedores de LLM",
    "settings.provider.githubCopilot": "Modelos GitHub Copilot",
    "settings.provider.geminiCli": "Modelos Google Gemini",
    "settings.system.title": "Sistema",
    "settings.system.autoUpdate": "Actualización automática",
    "settings.system.upToDate": "Actualizado",
    "settings.system.upToDateDescription": "Estás usando la última versión publicada.",
    "settings.system.checking": "Comprobando…",
    "settings.system.checkingDescription": "Contactando con el servidor de versiones para obtener la última versión.",
    "settings.system.updateAvailable": "Actualización disponible",
    "settings.system.updateAvailableDescription": "Usa « Buscar actualizaciones » en el menú para abrir la página de descarga.",
    "settings.system.idle": "Aún no comprobado",
    "settings.system.idleDescription": "La comprobación de actualizaciones se ejecuta automáticamente poco después del inicio.",
    "settings.system.errorStatus": "Error de comprobación",
    "settings.system.errorDescription": "No se pudo conectar con el servidor de versiones — comprueba tu conexión.",
    "settings.system.currentVersion": "Versión actual",
}

DE = {
    "settings.tab.images": "Bilder",
    "settings.tab.system": "System",
    "settings.agents.builtin": "Integrierte Anbieter",
    "settings.agents.builtinSubtitle": "API-Schlüssel direkt konfigurieren — keine CLI-Tools erforderlich.",
    "settings.agents.builtinEmpty": "Keine integrierten Anbieter konfiguriert.",
    "settings.agents.addProvider": "+ Anbieter hinzufügen",
    "settings.agents.acp": "ACP-Agent",
    "settings.agents.acpSubtitle": "Externe ACP-kompatible Agents verbinden.",
    "settings.agents.acpEmpty": "Keine ACP-Agents konfiguriert.",
    "settings.agents.addAcp": "+ Agent hinzufügen",
    "settings.agents.connect": "Verbinden",
    "settings.agents.disconnect": "Trennen",
    "settings.agents.claudeHint": "Du kannst zusätzliche Umgebungsvariablen in ~/.claude/settings.json festlegen.",
    "settings.mcp.server": "MCP-Server",
    "settings.mcp.running": "Läuft",
    "settings.mcp.stopped": "Gestoppt",
    "settings.mcp.port": "Port",
    "settings.mcp.start": "Starten",
    "settings.mcp.stop": "Stoppen",
    "settings.mcp.terminalIntegrations": "MCP-Integrationen im Terminal",
    "settings.mcp.terminalSubtitle1": "MCP-Integrationen werden nach einem Neustart des Terminals wirksam.",
    "settings.mcp.terminalSubtitle2": "Bitte installiere die MCP-Integrationen nach einem Upgrade von OpenPencil zur Kompatibilität neu.",
    "settings.images.search": "Bildersuche",
    "settings.images.ready": "Bereit",
    "settings.images.notConfigured": "Nicht konfiguriert",
    "settings.images.advanced": "Erweitert",
    "settings.images.oauthLabel": "Openverse OAuth (optional, für höhere Ratenlimits)",
    "settings.images.clientId": "Client-ID",
    "settings.images.clientSecret": "Client-Secret",
    "settings.images.registerLink": "Bei Openverse registrieren",
    "settings.images.test": "Testen",
    "settings.images.generation": "Bildgenerierung",
    "settings.images.add": "+ Hinzufügen",
    "settings.images.empty": "Noch keine Konfigurationen. Klicke auf „Hinzufügen“, um eine zu erstellen.",
    "settings.provider.claudeCode": "Claude-Modell",
    "settings.provider.codexCli": "OpenAI-Modelle",
    "settings.provider.openCode": "Über 75 LLM-Anbieter",
    "settings.provider.githubCopilot": "GitHub-Copilot-Modelle",
    "settings.provider.geminiCli": "Google-Gemini-Modelle",
    "settings.system.title": "System",
    "settings.system.autoUpdate": "Automatische Updates",
    "settings.system.upToDate": "Aktuell",
    "settings.system.upToDateDescription": "Du verwendest die neueste veröffentlichte Version.",
    "settings.system.checking": "Wird geprüft…",
    "settings.system.checkingDescription": "Der Versionsserver wird nach der neuesten Version abgefragt.",
    "settings.system.updateAvailable": "Update verfügbar",
    "settings.system.updateAvailableDescription": "Verwende „Nach Updates suchen“ im Menü, um die Downloadseite zu öffnen.",
    "settings.system.idle": "Noch nicht geprüft",
    "settings.system.idleDescription": "Eine Update-Prüfung wird kurz nach dem Start automatisch ausgeführt.",
    "settings.system.errorStatus": "Prüfung fehlgeschlagen",
    "settings.system.errorDescription": "Der Versionsserver ist nicht erreichbar — überprüfe deine Verbindung.",
    "settings.system.currentVersion": "Aktuelle Version",
}

PT = {
    "settings.tab.images": "Imagens",
    "settings.tab.system": "Sistema",
    "settings.agents.builtin": "Provedores integrados",
    "settings.agents.builtinSubtitle": "Configure as chaves de API diretamente — sem necessidade de ferramentas CLI.",
    "settings.agents.builtinEmpty": "Nenhum provedor integrado configurado.",
    "settings.agents.addProvider": "+ Adicionar provedor",
    "settings.agents.acp": "Agente ACP",
    "settings.agents.acpSubtitle": "Conecte agentes externos compatíveis com ACP.",
    "settings.agents.acpEmpty": "Nenhum agente ACP configurado.",
    "settings.agents.addAcp": "+ Adicionar agente",
    "settings.agents.connect": "Conectar",
    "settings.agents.disconnect": "Desconectar",
    "settings.agents.claudeHint": "Você pode definir variáveis de ambiente adicionais em ~/.claude/settings.json.",
    "settings.mcp.server": "Servidor MCP",
    "settings.mcp.running": "Em execução",
    "settings.mcp.stopped": "Parado",
    "settings.mcp.port": "Porta",
    "settings.mcp.start": "Iniciar",
    "settings.mcp.stop": "Parar",
    "settings.mcp.terminalIntegrations": "Integrações MCP do terminal",
    "settings.mcp.terminalSubtitle1": "As integrações MCP entram em vigor após reiniciar o terminal.",
    "settings.mcp.terminalSubtitle2": "Após atualizar o OpenPencil, reinstale as integrações MCP para garantir a compatibilidade.",
    "settings.images.search": "Busca de imagens",
    "settings.images.ready": "Pronto",
    "settings.images.notConfigured": "Não configurado",
    "settings.images.advanced": "Avançado",
    "settings.images.oauthLabel": "Openverse OAuth (opcional, para limites de taxa mais altos)",
    "settings.images.clientId": "ID do cliente",
    "settings.images.clientSecret": "Segredo do cliente",
    "settings.images.registerLink": "Registrar-se no Openverse",
    "settings.images.test": "Testar",
    "settings.images.generation": "Geração de imagens",
    "settings.images.add": "+ Adicionar",
    "settings.images.empty": "Ainda não há configurações. Clique em “Adicionar” para criar uma.",
    "settings.provider.claudeCode": "Modelo Claude",
    "settings.provider.codexCli": "Modelos OpenAI",
    "settings.provider.openCode": "Mais de 75 provedores de LLM",
    "settings.provider.githubCopilot": "Modelos GitHub Copilot",
    "settings.provider.geminiCli": "Modelos Google Gemini",
    "settings.system.title": "Sistema",
    "settings.system.autoUpdate": "Atualização automática",
    "settings.system.upToDate": "Atualizado",
    "settings.system.upToDateDescription": "Você está usando a versão publicada mais recente.",
    "settings.system.checking": "Verificando…",
    "settings.system.checkingDescription": "Contatando o servidor de versões para obter a versão mais recente.",
    "settings.system.updateAvailable": "Atualização disponível",
    "settings.system.updateAvailableDescription": "Use “Verificar atualizações” no menu para abrir a página de download.",
    "settings.system.idle": "Ainda não verificado",
    "settings.system.idleDescription": "Uma verificação de atualizações é executada automaticamente logo após a inicialização.",
    "settings.system.errorStatus": "Falha na verificação",
    "settings.system.errorDescription": "Não foi possível conectar ao servidor de versões — verifique sua conexão.",
    "settings.system.currentVersion": "Versão atual",
}

RU = {
    "settings.tab.images": "Изображения",
    "settings.tab.system": "Система",
    "settings.agents.builtin": "Встроенные провайдеры",
    "settings.agents.builtinSubtitle": "Настройте ключи API напрямую — инструменты CLI не нужны.",
    "settings.agents.builtinEmpty": "Встроенные провайдеры не настроены.",
    "settings.agents.addProvider": "+ Добавить провайдера",
    "settings.agents.acp": "Агент ACP",
    "settings.agents.acpSubtitle": "Подключение внешних ACP-совместимых агентов.",
    "settings.agents.acpEmpty": "Агенты ACP не настроены.",
    "settings.agents.addAcp": "+ Добавить агента",
    "settings.agents.connect": "Подключить",
    "settings.agents.disconnect": "Отключить",
    "settings.agents.claudeHint": "Дополнительные переменные среды можно задать в ~/.claude/settings.json.",
    "settings.mcp.server": "Сервер MCP",
    "settings.mcp.running": "Работает",
    "settings.mcp.stopped": "Остановлено",
    "settings.mcp.port": "Порт",
    "settings.mcp.start": "Запустить",
    "settings.mcp.stop": "Остановить",
    "settings.mcp.terminalIntegrations": "Интеграции MCP в терминале",
    "settings.mcp.terminalSubtitle1": "Интеграции MCP вступают в силу после перезапуска терминала.",
    "settings.mcp.terminalSubtitle2": "После обновления OpenPencil переустановите интеграции MCP для совместимости.",
    "settings.images.search": "Поиск изображений",
    "settings.images.ready": "Готово",
    "settings.images.notConfigured": "Не настроено",
    "settings.images.advanced": "Дополнительно",
    "settings.images.oauthLabel": "Openverse OAuth (необязательно, для повышения лимитов запросов)",
    "settings.images.clientId": "Идентификатор клиента",
    "settings.images.clientSecret": "Секрет клиента",
    "settings.images.registerLink": "Зарегистрироваться в Openverse",
    "settings.images.test": "Проверить",
    "settings.images.generation": "Генерация изображений",
    "settings.images.add": "+ Добавить",
    "settings.images.empty": "Конфигураций пока нет. Нажмите «Добавить», чтобы создать.",
    "settings.provider.claudeCode": "Модель Claude",
    "settings.provider.codexCli": "Модели OpenAI",
    "settings.provider.openCode": "Более 75 провайдеров LLM",
    "settings.provider.githubCopilot": "Модели GitHub Copilot",
    "settings.provider.geminiCli": "Модели Google Gemini",
    "settings.system.title": "Система",
    "settings.system.autoUpdate": "Автообновление",
    "settings.system.upToDate": "Актуально",
    "settings.system.upToDateDescription": "Используется последняя опубликованная версия.",
    "settings.system.checking": "Проверка…",
    "settings.system.checkingDescription": "Запрос последней версии у сервера выпусков.",
    "settings.system.updateAvailable": "Доступно обновление",
    "settings.system.updateAvailableDescription": "Выберите «Проверить обновления» в меню, чтобы открыть страницу загрузки.",
    "settings.system.idle": "Ещё не проверено",
    "settings.system.idleDescription": "Проверка обновлений выполняется автоматически вскоре после запуска.",
    "settings.system.errorStatus": "Ошибка проверки",
    "settings.system.errorDescription": "Не удалось связаться с сервером выпусков — проверьте подключение.",
    "settings.system.currentVersion": "Текущая версия",
}

HI = {
    "settings.tab.images": "छवियाँ",
    "settings.tab.system": "सिस्टम",
    "settings.agents.builtin": "अंतर्निहित प्रदाता",
    "settings.agents.builtinSubtitle": "API कुंजियाँ सीधे कॉन्फ़िगर करें — किसी CLI टूल की आवश्यकता नहीं।",
    "settings.agents.builtinEmpty": "कोई अंतर्निहित प्रदाता कॉन्फ़िगर नहीं किया गया।",
    "settings.agents.addProvider": "+ प्रदाता जोड़ें",
    "settings.agents.acp": "ACP एजेंट",
    "settings.agents.acpSubtitle": "बाहरी ACP-संगत एजेंट कनेक्ट करें।",
    "settings.agents.acpEmpty": "कोई ACP एजेंट कॉन्फ़िगर नहीं किया गया।",
    "settings.agents.addAcp": "+ एजेंट जोड़ें",
    "settings.agents.connect": "कनेक्ट करें",
    "settings.agents.disconnect": "डिस्कनेक्ट करें",
    "settings.agents.claudeHint": "आप ~/.claude/settings.json में अतिरिक्त एनवायरनमेंट वेरिएबल सेट कर सकते हैं।",
    "settings.mcp.server": "MCP सर्वर",
    "settings.mcp.running": "चल रहा है",
    "settings.mcp.stopped": "रुका हुआ",
    "settings.mcp.port": "पोर्ट",
    "settings.mcp.start": "प्रारंभ करें",
    "settings.mcp.stop": "रोकें",
    "settings.mcp.terminalIntegrations": "टर्मिनल MCP एकीकरण",
    "settings.mcp.terminalSubtitle1": "MCP एकीकरण टर्मिनल पुनः आरंभ करने के बाद प्रभावी होते हैं।",
    "settings.mcp.terminalSubtitle2": "OpenPencil अपग्रेड करने के बाद, संगतता के लिए MCP एकीकरण पुनः इंस्टॉल करें।",
    "settings.images.search": "छवि खोज",
    "settings.images.ready": "तैयार",
    "settings.images.notConfigured": "कॉन्फ़िगर नहीं किया गया",
    "settings.images.advanced": "उन्नत",
    "settings.images.oauthLabel": "Openverse OAuth (वैकल्पिक, उच्च दर सीमाओं के लिए)",
    "settings.images.clientId": "क्लाइंट ID",
    "settings.images.clientSecret": "क्लाइंट सीक्रेट",
    "settings.images.registerLink": "Openverse पर रजिस्टर करें",
    "settings.images.test": "परीक्षण करें",
    "settings.images.generation": "छवि निर्माण",
    "settings.images.add": "+ जोड़ें",
    "settings.images.empty": "अभी तक कोई कॉन्फ़िगरेशन नहीं। एक बनाने के लिए “जोड़ें” पर क्लिक करें।",
    "settings.provider.claudeCode": "Claude मॉडल",
    "settings.provider.codexCli": "OpenAI मॉडल",
    "settings.provider.openCode": "75+ LLM प्रदाता",
    "settings.provider.githubCopilot": "GitHub Copilot मॉडल",
    "settings.provider.geminiCli": "Google Gemini मॉडल",
    "settings.system.title": "सिस्टम",
    "settings.system.autoUpdate": "स्वतः अपडेट",
    "settings.system.upToDate": "नवीनतम",
    "settings.system.upToDateDescription": "आप नवीनतम प्रकाशित रिलीज़ चला रहे हैं।",
    "settings.system.checking": "जाँच रहा है…",
    "settings.system.checkingDescription": "नवीनतम संस्करण के लिए रिलीज़ सर्वर से संपर्क किया जा रहा है।",
    "settings.system.updateAvailable": "अपडेट उपलब्ध",
    "settings.system.updateAvailableDescription": "डाउनलोड पृष्ठ खोलने के लिए मेनू में “अपडेट जाँचें” का उपयोग करें।",
    "settings.system.idle": "अभी तक जाँचा नहीं गया",
    "settings.system.idleDescription": "लॉन्च के तुरंत बाद अपडेट जाँच स्वतः चलती है।",
    "settings.system.errorStatus": "जाँच विफल",
    "settings.system.errorDescription": "रिलीज़ सर्वर तक नहीं पहुँच सका — अपना कनेक्शन जाँचें।",
    "settings.system.currentVersion": "वर्तमान संस्करण",
}

TR = {
    "settings.tab.images": "Görseller",
    "settings.tab.system": "Sistem",
    "settings.agents.builtin": "Yerleşik sağlayıcılar",
    "settings.agents.builtinSubtitle": "API anahtarlarını doğrudan yapılandırın — CLI araçlarına gerek yok.",
    "settings.agents.builtinEmpty": "Yapılandırılmış yerleşik sağlayıcı yok.",
    "settings.agents.addProvider": "+ Sağlayıcı ekle",
    "settings.agents.acp": "ACP Aracısı",
    "settings.agents.acpSubtitle": "Harici ACP uyumlu aracıları bağlayın.",
    "settings.agents.acpEmpty": "Yapılandırılmış ACP aracısı yok.",
    "settings.agents.addAcp": "+ Aracı ekle",
    "settings.agents.connect": "Bağlan",
    "settings.agents.disconnect": "Bağlantıyı kes",
    "settings.agents.claudeHint": "~/.claude/settings.json içinde ek ortam değişkenleri ayarlayabilirsiniz.",
    "settings.mcp.server": "MCP Sunucusu",
    "settings.mcp.running": "Çalışıyor",
    "settings.mcp.stopped": "Durduruldu",
    "settings.mcp.port": "Bağlantı noktası",
    "settings.mcp.start": "Başlat",
    "settings.mcp.stop": "Durdur",
    "settings.mcp.terminalIntegrations": "Terminal MCP entegrasyonları",
    "settings.mcp.terminalSubtitle1": "MCP entegrasyonları terminal yeniden başlatıldıktan sonra etkinleşir.",
    "settings.mcp.terminalSubtitle2": "OpenPencil'i yükselttikten sonra uyumluluk için MCP entegrasyonlarını yeniden yükleyin.",
    "settings.images.search": "Görsel arama",
    "settings.images.ready": "Hazır",
    "settings.images.notConfigured": "Yapılandırılmadı",
    "settings.images.advanced": "Gelişmiş",
    "settings.images.oauthLabel": "Openverse OAuth (isteğe bağlı, daha yüksek hız sınırları için)",
    "settings.images.clientId": "İstemci kimliği",
    "settings.images.clientSecret": "İstemci gizli anahtarı",
    "settings.images.registerLink": "Openverse'e kaydol",
    "settings.images.test": "Test et",
    "settings.images.generation": "Görsel oluşturma",
    "settings.images.add": "+ Ekle",
    "settings.images.empty": "Henüz yapılandırma yok. Bir tane oluşturmak için “Ekle”'ye tıklayın.",
    "settings.provider.claudeCode": "Claude modeli",
    "settings.provider.codexCli": "OpenAI modelleri",
    "settings.provider.openCode": "75'ten fazla LLM sağlayıcısı",
    "settings.provider.githubCopilot": "GitHub Copilot modelleri",
    "settings.provider.geminiCli": "Google Gemini modelleri",
    "settings.system.title": "Sistem",
    "settings.system.autoUpdate": "Otomatik güncelleme",
    "settings.system.upToDate": "Güncel",
    "settings.system.upToDateDescription": "En son yayımlanan sürümü çalıştırıyorsunuz.",
    "settings.system.checking": "Denetleniyor…",
    "settings.system.checkingDescription": "En son sürüm için yayım sunucusuyla iletişim kuruluyor.",
    "settings.system.updateAvailable": "Güncelleme mevcut",
    "settings.system.updateAvailableDescription": "İndirme sayfasını açmak için menüdeki “Güncellemeleri Denetle”'yi kullanın.",
    "settings.system.idle": "Henüz denetlenmedi",
    "settings.system.idleDescription": "Güncelleme denetimi başlatmadan kısa süre sonra otomatik olarak çalışır.",
    "settings.system.errorStatus": "Denetim başarısız",
    "settings.system.errorDescription": "Yayım sunucusuna ulaşılamadı — bağlantınızı denetleyin.",
    "settings.system.currentVersion": "Geçerli sürüm",
}

TH = {
    "settings.tab.images": "รูปภาพ",
    "settings.tab.system": "ระบบ",
    "settings.agents.builtin": "ผู้ให้บริการในตัว",
    "settings.agents.builtinSubtitle": "กำหนดค่าคีย์ API โดยตรง — ไม่ต้องใช้เครื่องมือ CLI",
    "settings.agents.builtinEmpty": "ยังไม่ได้กำหนดค่าผู้ให้บริการในตัว",
    "settings.agents.addProvider": "+ เพิ่มผู้ให้บริการ",
    "settings.agents.acpSubtitle": "เชื่อมต่อ Agent ภายนอกที่รองรับ ACP",
    "settings.agents.acpEmpty": "ยังไม่ได้กำหนดค่า ACP Agent",
    "settings.agents.addAcp": "+ เพิ่ม Agent",
    "settings.agents.connect": "เชื่อมต่อ",
    "settings.agents.disconnect": "ยกเลิกการเชื่อมต่อ",
    "settings.agents.claudeHint": "คุณสามารถตั้งค่าตัวแปรสภาพแวดล้อมเพิ่มเติมได้ใน ~/.claude/settings.json",
    "settings.mcp.server": "เซิร์ฟเวอร์ MCP",
    "settings.mcp.running": "กำลังทำงาน",
    "settings.mcp.stopped": "หยุดแล้ว",
    "settings.mcp.port": "พอร์ต",
    "settings.mcp.start": "เริ่ม",
    "settings.mcp.stop": "หยุด",
    "settings.mcp.terminalIntegrations": "การผสานรวม MCP ของเทอร์มินัล",
    "settings.mcp.terminalSubtitle1": "การผสานรวม MCP จะมีผลหลังจากรีสตาร์ทเทอร์มินัล",
    "settings.mcp.terminalSubtitle2": "หลังจากอัปเกรด OpenPencil โปรดติดตั้งการผสานรวม MCP ใหม่เพื่อความเข้ากันได้",
    "settings.images.search": "ค้นหารูปภาพ",
    "settings.images.ready": "พร้อม",
    "settings.images.notConfigured": "ยังไม่ได้กำหนดค่า",
    "settings.images.advanced": "ขั้นสูง",
    "settings.images.oauthLabel": "Openverse OAuth (ไม่บังคับ สำหรับขีดจำกัดอัตราที่สูงขึ้น)",
    "settings.images.clientId": "ไคลเอ็นต์ ID",
    "settings.images.clientSecret": "ไคลเอ็นต์ซีเคร็ต",
    "settings.images.registerLink": "ลงทะเบียนที่ Openverse",
    "settings.images.test": "ทดสอบ",
    "settings.images.generation": "การสร้างรูปภาพ",
    "settings.images.add": "+ เพิ่ม",
    "settings.images.empty": "ยังไม่มีการกำหนดค่า คลิก “เพิ่ม” เพื่อสร้าง",
    "settings.provider.claudeCode": "โมเดล Claude",
    "settings.provider.codexCli": "โมเดล OpenAI",
    "settings.provider.openCode": "ผู้ให้บริการ LLM มากกว่า 75 ราย",
    "settings.provider.githubCopilot": "โมเดล GitHub Copilot",
    "settings.provider.geminiCli": "โมเดล Google Gemini",
    "settings.system.title": "ระบบ",
    "settings.system.autoUpdate": "อัปเดตอัตโนมัติ",
    "settings.system.upToDate": "เป็นเวอร์ชันล่าสุด",
    "settings.system.upToDateDescription": "คุณกำลังใช้รุ่นที่เผยแพร่ล่าสุด",
    "settings.system.checking": "กำลังตรวจสอบ…",
    "settings.system.checkingDescription": "กำลังติดต่อเซิร์ฟเวอร์รุ่นเพื่อหาเวอร์ชันล่าสุด",
    "settings.system.updateAvailable": "มีอัปเดต",
    "settings.system.updateAvailableDescription": "ใช้ “ตรวจหาการอัปเดต” ในเมนูเพื่อเปิดหน้าดาวน์โหลด",
    "settings.system.idle": "ยังไม่ได้ตรวจสอบ",
    "settings.system.idleDescription": "การตรวจหาอัปเดตจะทำงานอัตโนมัติไม่นานหลังจากเปิด",
    "settings.system.errorStatus": "ตรวจสอบล้มเหลว",
    "settings.system.errorDescription": "ไม่สามารถเข้าถึงเซิร์ฟเวอร์รุ่นได้ — โปรดตรวจสอบการเชื่อมต่อ",
    "settings.system.currentVersion": "เวอร์ชันปัจจุบัน",
}

VI = {
    "settings.tab.images": "Hình ảnh",
    "settings.tab.system": "Hệ thống",
    "settings.agents.builtin": "Nhà cung cấp tích hợp",
    "settings.agents.builtinSubtitle": "Cấu hình khóa API trực tiếp — không cần công cụ CLI.",
    "settings.agents.builtinEmpty": "Chưa cấu hình nhà cung cấp tích hợp nào.",
    "settings.agents.addProvider": "+ Thêm nhà cung cấp",
    "settings.agents.acp": "Agent ACP",
    "settings.agents.acpSubtitle": "Kết nối các Agent bên ngoài tương thích ACP.",
    "settings.agents.acpEmpty": "Chưa cấu hình Agent ACP nào.",
    "settings.agents.addAcp": "+ Thêm Agent",
    "settings.agents.connect": "Kết nối",
    "settings.agents.disconnect": "Ngắt kết nối",
    "settings.agents.claudeHint": "Bạn có thể đặt thêm biến môi trường trong ~/.claude/settings.json.",
    "settings.mcp.server": "Máy chủ MCP",
    "settings.mcp.running": "Đang chạy",
    "settings.mcp.stopped": "Đã dừng",
    "settings.mcp.port": "Cổng",
    "settings.mcp.start": "Bắt đầu",
    "settings.mcp.stop": "Dừng",
    "settings.mcp.terminalIntegrations": "Tích hợp MCP của terminal",
    "settings.mcp.terminalSubtitle1": "Tích hợp MCP có hiệu lực sau khi khởi động lại terminal.",
    "settings.mcp.terminalSubtitle2": "Sau khi nâng cấp OpenPencil, vui lòng cài đặt lại tích hợp MCP để đảm bảo tương thích.",
    "settings.images.search": "Tìm kiếm hình ảnh",
    "settings.images.ready": "Sẵn sàng",
    "settings.images.notConfigured": "Chưa cấu hình",
    "settings.images.advanced": "Nâng cao",
    "settings.images.oauthLabel": "Openverse OAuth (tùy chọn, để có giới hạn tốc độ cao hơn)",
    "settings.images.clientId": "ID khách hàng",
    "settings.images.clientSecret": "Khóa bí mật khách hàng",
    "settings.images.registerLink": "Đăng ký tại Openverse",
    "settings.images.test": "Kiểm tra",
    "settings.images.generation": "Tạo hình ảnh",
    "settings.images.add": "+ Thêm",
    "settings.images.empty": "Chưa có cấu hình nào. Nhấp “Thêm” để tạo một cấu hình.",
    "settings.provider.claudeCode": "Mô hình Claude",
    "settings.provider.codexCli": "Mô hình OpenAI",
    "settings.provider.openCode": "Hơn 75 nhà cung cấp LLM",
    "settings.provider.githubCopilot": "Mô hình GitHub Copilot",
    "settings.provider.geminiCli": "Mô hình Google Gemini",
    "settings.system.title": "Hệ thống",
    "settings.system.autoUpdate": "Tự động cập nhật",
    "settings.system.upToDate": "Đã cập nhật",
    "settings.system.upToDateDescription": "Bạn đang chạy bản phát hành mới nhất.",
    "settings.system.checking": "Đang kiểm tra…",
    "settings.system.checkingDescription": "Đang liên hệ máy chủ phát hành để lấy phiên bản mới nhất.",
    "settings.system.updateAvailable": "Có bản cập nhật",
    "settings.system.updateAvailableDescription": "Dùng “Kiểm tra cập nhật” trong menu để mở trang tải xuống.",
    "settings.system.idle": "Chưa kiểm tra",
    "settings.system.idleDescription": "Quá trình kiểm tra cập nhật tự động chạy ngay sau khi khởi động.",
    "settings.system.errorStatus": "Kiểm tra thất bại",
    "settings.system.errorDescription": "Không thể kết nối máy chủ phát hành — hãy kiểm tra kết nối của bạn.",
    "settings.system.currentVersion": "Phiên bản hiện tại",
}

ID = {
    "settings.tab.images": "Gambar",
    "settings.tab.system": "Sistem",
    "settings.agents.builtin": "Penyedia bawaan",
    "settings.agents.builtinSubtitle": "Konfigurasikan kunci API secara langsung — tidak perlu alat CLI.",
    "settings.agents.builtinEmpty": "Tidak ada penyedia bawaan yang dikonfigurasi.",
    "settings.agents.addProvider": "+ Tambah penyedia",
    "settings.agents.acp": "Agent ACP",
    "settings.agents.acpSubtitle": "Hubungkan Agent eksternal yang kompatibel dengan ACP.",
    "settings.agents.acpEmpty": "Tidak ada Agent ACP yang dikonfigurasi.",
    "settings.agents.addAcp": "+ Tambah Agent",
    "settings.agents.connect": "Hubungkan",
    "settings.agents.disconnect": "Putuskan",
    "settings.agents.claudeHint": "Anda dapat menyetel variabel lingkungan tambahan di ~/.claude/settings.json.",
    "settings.mcp.server": "Server MCP",
    "settings.mcp.running": "Berjalan",
    "settings.mcp.stopped": "Dihentikan",
    "settings.mcp.port": "Port",
    "settings.mcp.start": "Mulai",
    "settings.mcp.stop": "Hentikan",
    "settings.mcp.terminalIntegrations": "Integrasi MCP terminal",
    "settings.mcp.terminalSubtitle1": "Integrasi MCP berlaku setelah memulai ulang terminal.",
    "settings.mcp.terminalSubtitle2": "Setelah memperbarui OpenPencil, instal ulang integrasi MCP untuk kompatibilitas.",
    "settings.images.search": "Pencarian gambar",
    "settings.images.ready": "Siap",
    "settings.images.notConfigured": "Tidak dikonfigurasi",
    "settings.images.advanced": "Lanjutan",
    "settings.images.oauthLabel": "Openverse OAuth (opsional, untuk batas laju lebih tinggi)",
    "settings.images.clientId": "ID Klien",
    "settings.images.clientSecret": "Rahasia Klien",
    "settings.images.registerLink": "Daftar di Openverse",
    "settings.images.test": "Uji",
    "settings.images.generation": "Pembuatan gambar",
    "settings.images.add": "+ Tambah",
    "settings.images.empty": "Belum ada konfigurasi. Klik “Tambah” untuk membuat satu.",
    "settings.provider.claudeCode": "Model Claude",
    "settings.provider.codexCli": "Model OpenAI",
    "settings.provider.openCode": "75+ penyedia LLM",
    "settings.provider.githubCopilot": "Model GitHub Copilot",
    "settings.provider.geminiCli": "Model Google Gemini",
    "settings.system.title": "Sistem",
    "settings.system.autoUpdate": "Pembaruan otomatis",
    "settings.system.upToDate": "Terbaru",
    "settings.system.upToDateDescription": "Anda menjalankan rilis terbaru yang dipublikasikan.",
    "settings.system.checking": "Memeriksa…",
    "settings.system.checkingDescription": "Menghubungi server rilis untuk versi terbaru.",
    "settings.system.updateAvailable": "Pembaruan tersedia",
    "settings.system.updateAvailableDescription": "Gunakan “Periksa Pembaruan” di menu untuk membuka halaman unduhan.",
    "settings.system.idle": "Belum diperiksa",
    "settings.system.idleDescription": "Pemeriksaan pembaruan berjalan otomatis sesaat setelah peluncuran.",
    "settings.system.errorStatus": "Pemeriksaan gagal",
    "settings.system.errorDescription": "Tidak dapat menjangkau server rilis — periksa koneksi Anda.",
    "settings.system.currentVersion": "Versi saat ini",
}

LOCALES = [
    ("en", {}), ("zh_cn", ZH_CN), ("zh_tw", ZH_TW), ("ja", JA), ("ko", KO),
    ("fr", FR), ("es", ES), ("de", DE), ("pt", PT), ("ru", RU), ("hi", HI),
    ("tr", TR), ("th", TH), ("vi", VI), ("id", ID),
]

NEW_HEADER = [
    "//! Canonical chrome-string table for this locale.\n",
    "//!\n",
    "//! Formerly generated from `apps/web/src/i18n/locales/*.ts` via\n",
    "//! `tools/convert-locales.py`; that TS pipeline is retired and\n",
    "//! these tables are now hand-maintained directly.\n",
]


def esc(s):
    return s.replace("\\", "\\\\").replace('"', '\\"')


def main():
    for name, ov in LOCALES:
        path = os.path.join(I18N_DIR, name + ".rs")
        with open(path, "r", encoding="utf-8") as f:
            lines = f.readlines()

        # 1. Refresh the doc-comment header (drop the "generated, do
        #    NOT hand-edit" banner — these tables are canonical now).
        if lines and lines[0].startswith("//! Generated from"):
            end = 0
            while end < len(lines) and lines[end].startswith("//!"):
                end += 1
            lines = NEW_HEADER + lines[end:]

        # 2. Insert the settings.* block before `_ => return None,`.
        if any('"settings.tab.agents"' in ln for ln in lines):
            print(f"{name}: already has settings.* block, skipping insert")
        else:
            table = dict(EN)
            table.update(ov)
            block = [
                '        "{}" => "{}",\n'.format(k, esc(table[k])) for k in KEYS
            ]
            for i, ln in enumerate(lines):
                if ln.strip() == "_ => return None,":
                    lines[i:i] = block
                    break
            else:
                raise SystemExit(f"{name}: no `_ => return None,` arm found")

        with open(path, "w", encoding="utf-8") as f:
            f.writelines(lines)
        print(f"{name}: done")


if __name__ == "__main__":
    main()
