Metadata-Version: 2.4
Name: code-translator-cn-demo
Version: 1.0.0
Summary: 将Python代码功能翻译成中文，支持中文API编写代码
Project-URL: Homepage, https://github.com/example/code-translator-cn
Project-URL: Issues, https://github.com/example/code-translator-cn/issues
Author-email: Code Translator <codetranslator@example.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Internationalization
Requires-Python: >=3.8
Requires-Dist: astor
Description-Content-Type: text/markdown

# code-translator-cn

将Python代码功能翻译成中文，支持中文API编写代码。

## 功能特性

- **代码翻译**: 使用AST解析Python代码，自动翻译函数、类、方法、变量等名称
- **中文API**: 提供中文函数名包装，可直接用中文编写代码
- **动态导入器**: 导入不常见库时自动识别并翻译
- **自动文档生成**: 导入模块后自动生成翻译文档

## 安装

```bash
pip install code-translator-cn
```

## 使用示例

### 基础用法

```python
from code_translator import *

# 翻译代码
代码 = """
import math
result = math.sin(3.14)
"""
翻译结果 = translate_code(代码)
print(翻译结果)
```

### 中文API

```python
from code_translator import *

# 使用中文函数名
数学.正弦(3.14)  # math.sin(3.14)
文件系统.读取文件('test.txt')  # 读取文件
控制台.打印('你好世界')  # print('Hello World')
```

### 动态导入

```python
from code_translator import 导入

# 导入不常见模块并自动翻译
base64中文 = 导入('base64')
base64中文.b64编码('测试'.encode())

# 导入并添加到全局命名空间
导入并使用('base64')
b64编码('测试'.encode())
```

## 命令行工具

```bash
# 翻译代码文件
code-translate translate input.py output.txt

# 翻译模块并生成文档
code-translate import base64
```

## 项目结构

```
code_translator/
├── __init__.py          # 模块入口
├── parser.py            # 代码解析器
├── translator.py        # 翻译生成器
├── common_libs.py       # 常见库翻译字典
├── chinese_api.py       # 中文API模块
├── dynamic_importer.py  # 动态导入器
├── cli.py               # 命令行接口
└── docs/                # 自动生成的翻译文档
```

## 支持的库

- **标准库**: math, random, datetime, os, json, re, urllib, collections, itertools, functools 等
- **动态导入**: 支持任意Python模块的自动翻译

## 许可证

MIT License

## 贡献

欢迎提交问题和PR！
