TRANSLATIONS = {
    'zh_CN': {
        # 通用
        'admin_title': 'Robyn Admin',
        'login': '登录',
        'logout': '退出',
        'welcome': '欢迎',
        'home': '首页',
        'search': '搜索',
        'reset': '重置',
        'submit': '提交',
        'cancel': '取消',
        'save': '保存',
        'add': '添加',
        'edit': '编辑',
        'delete': '删除',
        'batch_delete': '批量删除',
        'export': '导出',
        'yes': '是',
        'no': '否',
        'normal': '正常',
        'disabled': '禁用',
        'all': '全部',

        # 状态
        'status': '状态',
        'active': '正常',
        'inactive': '禁用',
        'is_superuser': '管理员',

        # 表单
        'username': '用户名',
        'email': '邮箱',
        'password': '密码',
        'created_at': '创建时间',
        'updated_at': '更新时间',
        'last_login': '最后登录',

        # 提示信息
        'confirm_delete': '确定要删除吗？',
        'operation_success': '操作成功',
        'operation_failed': '操作失败',
        'please_select': '请选择',
        'loading': '加载中...',
        'no_data': '暂无数据',

        # 表格操作
        'operation': '操作',
        'selected_items': '已选择 {count} 条记录',
        'clear_selection': '清除选择',
        'please_select_items': '请选择要删除的记录',
        'confirm_batch_delete': '确定要删除选中的 {count} 条记录吗？',
        'deleting': '删除中...',
        'export_selected': '导出选中',
        'export_current': '导出当前页',
        'switch_language_failed': '切换语言失败',
        'load_failed': '加载数据失败，请刷新页面重试',
        'delete_failed': '删除失败，请重试',
        'delete_success': '删除成功',
        'delete_partial': '部分删除成功',
        'refresh': '刷新',
        'toggle_view': '切换视图',
        'columns': '列',
        'search_placeholder': '搜索...',
        'no_records_found': '没有找到匹配的记录',
        'pagination_info': '显示第 {from} 到 {to} 条记录，共 {total} 条',
        'edit': '编辑',
        'row_delete': '删除',
        'import': '导入',
        # 过滤器相关
        'start_date': '开始日期',
        'end_date': '结束日期',
        'date_separator': '至',
        'min_value': '最小值',
        'max_value': '最大值',
        'number_separator': '至',
        'filter_placeholder': '请输入{field}',
        'select_placeholder': '请选择{field}',
        'list': '列表',

        # 系统管理菜单
        'system_management': '系统管理',
        'user_management': '用户管理',
        'role_management': '角色管理',
        'user_role_management': '用户角色管理',

        # 导入相关
        'import_data': '导入数据',
        'select_file': '选择文件',
        'supported_formats': '支持的格式: Excel (.xlsx, .xls), CSV (.csv)',
        'required_fields': '必需字段',
        'import_button': '导入',

        # 文件上传相关
        'choose_file': '选择文件',
        'no_file_chosen': '未选择文件',
        'please_select_file': '请选择文件',
    },
    'en_US': {
        # Common
        'admin_title': 'Robyn Admin',
        'login': 'Login',
        'logout': 'Logout',
        'welcome': 'Welcome',
        'home': 'Home',
        'search': 'Search',
        'reset': 'Reset',
        'submit': 'Submit',
        'cancel': 'Cancel',
        'save': 'Save',
        'add': 'Add',
        'edit': 'Edit',
        'delete': 'Delete',
        'batch_delete': 'Batch Delete',
        'export': 'Export',
        'yes': 'Yes',
        'no': 'No',
        'normal': 'Normal',
        'disabled': 'Disabled',
        'all': 'All',

        # Status
        'status': 'Status',
        'active': 'Active',
        'inactive': 'Inactive',
        'is_superuser': 'Administrator',

        # Form
        'username': 'Username',
        'email': 'Email',
        'password': 'Password',
        'created_at': 'Created At',
        'updated_at': 'Updated At',
        'last_login': 'Last Login',

        # Messages
        'confirm_delete': 'Are you sure you want to delete?',
        'operation_success': 'Operation Success',
        'operation_failed': 'Operation Failed',
        'please_select': 'Please Select',
        'loading': 'Loading...',
        'no_data': 'No Data',

        # Table Operations
        'operation': 'Operations',
        'selected_items': '{count} items selected',
        'clear_selection': 'Clear Selection',
        'please_select_items': 'Please select items to delete',
        'confirm_batch_delete': 'Are you sure to delete {count} selected items?',
        'deleting': 'Deleting...',
        'export_selected': 'Exported {count} selected items',
        'export_current': 'Exported all items in current page',
        'switch_language_failed': 'Failed to switch language',
        'load_failed': 'Failed to load data, please refresh the page',
        'delete_failed': 'Delete failed, please try again',
        'delete_success': 'Delete successful',
        'delete_partial': 'Partially deleted',
        'refresh': 'Refresh',
        'toggle_view': 'Toggle View',
        'columns': 'Columns',
        'search_placeholder': 'Search...',
        'no_records_found': 'No matching records found',
        'pagination_info': 'Showing {from} to {to} of {total} entries',
        'edit': 'edit',
        'row_delete': 'delete',
        'import': 'Import',
        # Filter related
        'start_date': 'Start Date',
        'end_date': 'End Date',
        'date_separator': 'to',
        'min_value': 'Min',
        'max_value': 'Max',
        'number_separator': 'to',
        'filter_placeholder': 'Enter {field}',
        'select_placeholder': 'Select {field}',
        'list': 'List',

        # System Management Menu
        'system_management': 'System Management',
        'user_management': 'User Management',
        'role_management': 'Role Management',
        'user_role_management': 'User Role Management',

        # 导入相关
        'import_data': 'Import Data',
        'select_file': 'Select File',
        'supported_formats': 'Supported formats: Excel (.xlsx, .xls), CSV (.csv)',
        'required_fields': 'Required fields',
        'import_button': 'Import',

        # 文件上传相关
        'choose_file': 'Choose File',
        'no_file_chosen': 'No file chosen',
        'please_select_file': 'Please select a file',
    }
}

def get_text(key: str, lang: str = None) -> str:
    """获取指定语言的文本"""
    # 如果没有指定语言，使用英文作为默认值
    default_lang = 'en_US'
    current_lang = lang or default_lang
    return TRANSLATIONS.get(current_lang, TRANSLATIONS[default_lang]).get(key, key) 