5 Commits
v0.1.0 ... main

Author SHA1 Message Date
7fe67854cd added readme
All checks were successful
Pack Validation CI / validate (push) Successful in 7s
Trigger Docs Rebuild / trigger (push) Successful in 2s
2026-05-21 15:14:03 +00:00
ccee29236e Merge pull request 'bumped version' (#6) from version-bump into main
All checks were successful
Pack Validation CI / validate (push) Successful in 7s
Publish Language Pack / verify (push) Successful in 7s
Publish Language Pack / publish (push) Successful in 14s
Reviewed-on: #6
2026-05-21 15:02:40 +00:00
CT
922a2c7b30 bumped version
All checks were successful
Pack Validation CI / validate (pull_request) Successful in 8s
2026-05-21 10:01:48 -05:00
b5ecb796da Merge pull request 'added errors and exceptions' (#5) from exceptions into main
All checks were successful
Pack Validation CI / validate (push) Successful in 8s
Reviewed-on: #5
2026-05-21 15:00:14 +00:00
CT
ab58b4a830 added errors and exceptions
All checks were successful
Pack Validation CI / validate (pull_request) Successful in 9s
2026-05-21 09:58:51 -05:00
3 changed files with 162 additions and 45 deletions

117
README.md
View File

@@ -1 +1,118 @@
# foreignthon-zh
Chinese language pack for [ForeignThon](https://foreignthon.keshavanand.net/) — write Python in 中文.
---
## Install
```bash
pip install foreignthon foreignthon-zh
```
---
## Example
**`fizzbuzz.zh.py`**
```python
定义 fizzbuzz(n):
对于 i 范围(1, n + 1):
如果 i % 15 == 0:
打印("FizzBuzz")
不然 i % 3 == 0:
打印("Fizz")
不然 i % 5 == 0:
打印("Buzz")
否则:
打印(i)
fizzbuzz(20)
```
Compiles to standard Python:
```python
def fizzbuzz(n):
for i in range(1, n + 1):
if i % 15 == 0:
print("FizzBuzz")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else:
print(i)
fizzbuzz(20)
```
Run it directly:
```bash
fpy run fizzbuzz.zh.py
```
---
## Keyword reference
| Python | 中文 |
|---|---|
| `if` | `如果` |
| `else` | `否则` |
| `elif` | `不然` |
| `for` | `对于` |
| `while` | `只要` |
| `def` | `函数` / `定义` |
| `class` | `类` / `类别` |
| `return` | `返回` |
| `import` | `导入` |
| `from` | `从` |
| `as` | `名` |
| `in` | `在` |
| `and` | `和` |
| `or` | `或` |
| `not` | `不` |
| `True` | `真` |
| `False` | `假` |
| `None` | `空` |
| `print` | `打印` / `写` |
| `input` | `扫描` |
| `len` | `长度` |
| `range` | `范围` |
| `lambda` | `匿名` / `λ` |
| `yield` | `产生` |
| `async` | `非同步` |
| `await` | `等` |
Full mapping: [`zh.json`](https://git.keshavanand.net/foreign-thon/foreignthon-zh/raw/branch/main/src/foreignthon_zh/zh.json)
---
## Start a project
```bash
fpy new myproject --lang zh
cd myproject
fpy run src/main.zh.py
```
---
## Documentation
→ [foreignthon.keshavanand.net](https://foreignthon.keshavanand.net/)
---
## Contributing
Found a missing translation or a better keyword choice? Open an issue or PR — no access to the core repo needed.
---
## License
GPL v3

View File

@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "foreignthon-zh"
version = "0.1.0"
version = "0.2.0"
description = "Chinese language pack for ForeignThon."
license = { text = "GPL v3" }
requires-python = ">=3.9"

View File

@@ -87,57 +87,57 @@
"八进制": "oct"
},
"exceptions": {
"Exception": "Exception",
"BaseException": "BaseException",
"ValueError": "ValueError",
"TypeError": "TypeError",
"KeyError": "KeyError",
"IndexError": "IndexError",
"AttributeError": "AttributeError",
"NameError": "NameError",
"ImportError": "ImportError",
"FileNotFoundError": "FileNotFoundError",
"RuntimeError": "RuntimeError",
"ZeroDivisionError": "ZeroDivisionError",
"SyntaxError": "SyntaxError",
"AssertionError": "AssertionError",
"MemoryError": "MemoryError",
"OverflowError": "OverflowError",
"RecursionError": "RecursionError",
"PermissionError": "PermissionError",
"TimeoutError": "TimeoutError",
"SystemExit": "SystemExit",
"KeyboardInterrupt": "KeyboardInterrupt"
"異常": "Exception",
"基异常": "BaseException",
"值异常": "ValueError",
"类型异常": "TypeError",
"键值异常": "KeyError",
"索引异常": "IndexError",
"属性异常": "AttributeError",
"名称异常": "NameError",
"载入异常": "ImportError",
"档案未找到异常": "FileNotFoundError",
"运行时异常": "RuntimeError",
"除零异常": "ZeroDivisionError",
"句法异常": "SyntaxError",
"断言异常": "AssertionError",
"记忆体异常": "MemoryError",
"溢值异常": "OverflowError",
"递归异常": "RecursionError",
"权限异常": "PermissionError",
"超时异常": "TimeoutError",
"退出系统": "SystemExit",
"键盘中断": "KeyboardInterrupt"
},
"error_messages": {
"SyntaxError": "SyntaxError",
"ValueError": "ValueError",
"TypeError": "TypeError",
"KeyError": "KeyError",
"IndexError": "IndexError",
"AttributeError": "AttributeError",
"NameError": "NameError",
"ImportError": "ImportError",
"FileNotFoundError": "FileNotFoundError",
"ZeroDivisionError": "ZeroDivisionError",
"RecursionError": "RecursionError",
"RuntimeError": "RuntimeError",
"MemoryError": "MemoryError",
"OverflowError": "OverflowError",
"AssertionError": "AssertionError",
"PermissionError": "PermissionError",
"TimeoutError": "TimeoutError",
"KeyboardInterrupt": "KeyboardInterrupt"
"SyntaxError": "句法异常",
"ValueError": "值异常",
"TypeError": "类型异常",
"KeyError": "键值异常",
"IndexError": "索引异常",
"AttributeError": "属性异常",
"NameError": "名称异常",
"ImportError": "载入异常",
"FileNotFoundError": "档案未找到异常",
"ZeroDivisionError": "除零异常",
"RecursionError": "递归异常",
"RuntimeError": "运行时异常",
"MemoryError": "属性异常",
"OverflowError": "属性异常",
"AssertionError": "属性异常",
"PermissionError": "权限异常",
"TimeoutError": "超时异常",
"KeyboardInterrupt": "键盘中断"
},
"stdlib": {
"数学": "math",
"系统": "sys",
"日期时间": "datetime",
"时间": "time",
"random": "random",
"collections": "collections",
"pathlib": "pathlib",
"re": "re"
"随机": "random",
"收藏": "collections",
"路径库": "pathlib",
"正则表达式": "re"
},
"postfix_keywords": []
}