export const translations = {
  en: {
    // Sidebar
    Start: "Start",
    Dashboard: "Dashboard",
    "Knowledge Bases": "Knowledge Bases",
    Settings: "Settings",

    // Common
    Loading: "Loading...",
    Save: "Save",
    Cancel: "Cancel",
    Error: "Error",
    Success: "Success",
    "View All": "View All",
    Refresh: "Refresh",
    Create: "Create",

    // Settings Page
    "System Settings": "System Settings",
    "Manage system configuration and preferences":
      "Manage system configuration and preferences",
    "General Settings": "General Settings",
    "Environment Variables": "Environment Variables",
    "Interface Preferences": "Interface Preferences",
    Theme: "Theme",
    "Light Mode": "Light Mode",
    "Dark Mode": "Dark Mode",
    Language: "Language",
    English: "English",
    Chinese: "Chinese",
    "System Configuration": "System Configuration",
    "System Language": "System Language",
    "Default language for system operations":
      "Default language for system operations",
    WebSearch: "Web",
    "Max Results": "Max Results",
    "Knowledge Base": "Knowledge Base",
    "Default KB": "Default KB",
    "Base Directory": "Base Directory",
    "Text-to-Speech": "Text-to-Speech",
    "Default Voice": "Default Voice",
    "Default Language": "Default Language",
    "Active Models": "Active Models",
    Status: "Status",
    "Active LLM Model": "Active LLM Model",
    "Not configured": "Not configured",
    "Configure in Environment Variables tab":
      "Configure in Environment Variables tab",
    "Save All Changes": "Save All Changes",
    "Configuration Saved": "Configuration Saved",
    "Configuration Status": "Configuration Status",
    "Refresh Status": "Refresh Status",
    "Runtime Configuration": "Runtime Configuration",
    "Environment variables are loaded from":
      "Environment variables are loaded from",
    "file on startup": "file on startup",
    "Changes made here take effect immediately but are not saved to file":
      "Changes made here take effect immediately but are not saved to file",
    "On restart, values will be reloaded from":
      "On restart, values will be reloaded from",
    "Apply Environment Changes": "Apply Environment Changes",
    "Environment Updated!": "Environment Updated!",
    "Configured (enter new value to update)": "Configured (enter new value to update)",
    Show: "Show",
    Hide: "Hide",
    REQUIRED: "REQUIRED",
    "Error loading data": "Error loading data",
    "Failed to load settings": "Failed to load settings",
    "Failed to connect to backend": "Failed to connect to backend",

    // Dashboard Page
    "Overview of your recent learning activities":
      "Overview of your recent learning activities",
    "Recent Activity": "Recent Activity",
    "Loading activities...": "Loading activities...",
    "No recent activity found": "No recent activity found",
    "Start exploring knowledge bases!":
      "Start exploring knowledge bases!",
    Activity: "Activity",
    records: "records",
    "System Status": "System Status",
    "Quick Actions": "Quick Actions",
    "Ask a Question": "Ask a Question",

    // Home Page
    Home: "Home",
    History: "History",
    "Welcome to Sirchmunk": "Welcome to Sirchmunk",
    "Search to Learn, Evolve to Find.": "Search to Learn, Evolve to Find.",
    "Ask anything...": "Ask anything...",
    "Input message or search the web via g: xx or G: xx ...": "Input message or search the web via g: xx or G: xx ...",
    FileSystem: "File",
    "Select Knowledge Base": "Select Knowledge Base",
    "Explore Modules": "Explore Modules",
    "Searching knowledge base...": "Searching knowledge base...",
    "Searching the web...": "Searching the web...",
    "Generating response...": "Generating response...",
    "Clear Chat": "Clear Chat",
    Sources: "Sources",
    References: "References",
    Suggest: "Suggest",
    "Toggle file suggestions while typing": "Toggle file suggestions while typing",
    "From Knowledge Base": "From Knowledge Base",
    "From Web": "From Web",
    "New Chat": "New Chat",
    "Stop generating": "Stop generating",
    "Select File": "Select File",
    "Select Folder": "Select Folder",
    "Select File or Folder": "Select File or Folder",
    "Single File": "Single File",
    Folder: "Folder",
    "Custom Path": "Custom Path",
    Confirm: "Confirm",
    "Go up": "Go up",
    "Empty folder": "Empty folder",
    "Show hidden files": "Show hidden files",
    "Select Current Folder": "Select Current Folder",
    Select: "Select",
    "Failed to open file picker": "Failed to open file picker",
    "Failed to open folder picker": "Failed to open folder picker",
    "Search Mode": "Search Mode",
    FAST: "FAST",
    DEEP: "DEEP",
    FILENAME_ONLY: "FILENAME",
    "FAST Desc": "Greedy search, fastest",
    "DEEP Desc": "Comprehensive analysis",
    "FILENAME_ONLY Desc": "Filename matching only",

    // History Page
    "Chat History": "Chat History",
    "All Activities": "All Activities",
    "Filter by type": "Filter by type",
    All: "All",
    Chat: "Chat",
    "No history found": "No history found",
    "Your activities will appear here": "Your activities will appear here",
    Continue: "Continue",
  },
  zh: {
    // Sidebar
    Start: "开始",
    Dashboard: "仪表盘",
    "Knowledge Bases": "知识库",
    Settings: "设置",

    // Common
    Loading: "加载中...",
    Save: "保存",
    Cancel: "取消",
    Error: "错误",
    Success: "成功",
    "View All": "查看全部",
    Refresh: "刷新",
    Create: "创建",

    // Settings Page
    "System Settings": "系统设置",
    "Manage system configuration and preferences": "管理系统配置和偏好设置",
    "General Settings": "常规设置",
    "Environment Variables": "环境变量",
    "Interface Preferences": "界面偏好",
    Theme: "主题",
    "Light Mode": "浅色模式",
    "Dark Mode": "深色模式",
    Language: "语言",
    English: "英语",
    Chinese: "中文",
    "System Configuration": "系统配置",
    "System Language": "系统语言",
    "Default language for system operations": "系统操作的默认语言",
    WebSearch: "网络",
    "Max Results": "最大结果数",
    "Knowledge Base": "知识库",
    "Default KB": "默认知识库",
    "Base Directory": "基础目录",
    "Text-to-Speech": "文字转语音",
    "Default Voice": "默认语音",
    "Default Language": "默认语言",
    "Active Models": "活动模型",
    Status: "状态",
    "Active LLM Model": "当前 LLM 模型",
    "Not configured": "未配置",
    "Configure in Environment Variables tab": "请在环境变量标签页中配置",
    "Save All Changes": "保存所有更改",
    "Configuration Saved": "配置已保存",
    "Configuration Status": "配置状态",
    "Refresh Status": "刷新状态",
    "Runtime Configuration": "运行时配置",
    "Environment variables are loaded from": "环境变量从",
    "file on startup": "文件加载于启动时",
    "Changes made here take effect immediately but are not saved to file":
      "此处的更改立即生效但不会保存到文件",
    "On restart, values will be reloaded from":
      "重启后，值将从以下文件重新加载",
    "Apply Environment Changes": "应用环境变量更改",
    "Environment Updated!": "环境变量已更新！",
    "Configured (enter new value to update)": "已配置（输入新值以更新）",
    Show: "显示",
    Hide: "隐藏",
    REQUIRED: "必填",
    "Error loading data": "加载数据出错",
    "Failed to load settings": "加载设置失败",
    "Failed to connect to backend": "连接后端失败",

    // Dashboard Page
    "Overview of your recent learning activities": "您最近的学习活动概览",
    "Recent Activity": "最近活动",
    "Loading activities...": "加载活动中...",
    "No recent activity found": "未找到最近活动",
    "Start exploring knowledge bases!": "开始探索知识库吧！",
    Activity: "活动",
    records: "条记录",
    "System Status": "系统状态",
    "Quick Actions": "快捷操作",
    "Ask a Question": "提问问题",

    // Home Page
    Home: "首页",
    History: "历史记录",
    "Welcome to Sirchmunk": "欢迎使用 Sirchmunk",
    "Search to Learn, Evolve to Find.": "搜索以学习，进化以发现。",
    "Ask anything...": "问我任何问题...",
    "Type your message...": "输入消息，或使用前缀 g: xxx 或 G: xxx 跳转到搜索引擎",
    FileSystem: "文件",
    "Select Knowledge Base": "选择知识库",
    "Explore Modules": "探索模块",
    "Searching knowledge base...": "正在搜索知识库...",
    "Searching the web...": "正在搜索网络...",
    "Generating response...": "正在生成回复...",
    "Clear Chat": "清空对话",
    Sources: "来源",
    References: "参考",
    Suggest: "联想",
    "Toggle file suggestions while typing": "输入时显示文件联想",
    "From Knowledge Base": "来自知识库",
    "From Web": "来自网络",
    "New Chat": "新对话",
    "Stop generating": "停止生成",
    "Select File": "选择文件",
    "Select Folder": "选择文件夹",
    "Select File or Folder": "选择文件或文件夹",
    "Single File": "单文件",
    Folder: "文件夹",
    "Custom Path": "自定义路径",
    Confirm: "确认",
    "Go up": "上一层",
    "Empty folder": "空文件夹",
    "Show hidden files": "显示隐藏文件",
    "Select Current Folder": "选择当前文件夹",
    Select: "选择",
    "Failed to open file picker": "无法打开文件选择器",
    "Failed to open folder picker": "无法打开文件夹选择器",
    "Search Mode": "搜索模式",
    FAST: "快速",
    DEEP: "深度",
    FILENAME_ONLY: "文件名",
    "FAST Desc": "贪心搜索，最快",
    "DEEP Desc": "全面分析",
    "FILENAME_ONLY Desc": "仅文件名匹配",

    // History Page
    "Chat History": "聊天历史",
    "All Activities": "所有活动",
    "Filter by type": "按类型筛选",
    All: "全部",
    Chat: "聊天",
    "No history found": "未找到历史记录",
    "Your activities will appear here": "您的活动将显示在这里",
    Continue: "继续对话",
  },
};

export type Language = "en" | "zh";

export function getTranslation(lang: Language, key: string): string {
  const dict = translations[lang] || translations.en;
  return dict[key as keyof typeof dict] || key;
}

// Hook helper for components
export function useTranslation(lang: Language) {
  return (key: string) => getTranslation(lang, key);
}
