5 Commits

Author SHA1 Message Date
CT
f7de0fc671 more words added 2026-05-18 14:38:46 -05:00
CT
773e56b619 changed more words 2026-05-18 11:44:02 -05:00
CT
e5cc2e2feb changed ch to zh 2026-05-17 12:41:09 -05:00
CT
3fe496f8d9 created chinese dir 2026-05-17 10:56:03 -05:00
CT
3093b4328d added chinese to docs 2026-05-17 10:55:16 -05:00
7 changed files with 182 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ foreignthon/
│ └── langs/ │ └── langs/
│ ├── es/ # foreignthon-es (Spanish) │ ├── es/ # foreignthon-es (Spanish)
│ └── ta/ # foreignthon-ta (Tamil) │ └── ta/ # foreignthon-ta (Tamil)
| |__ zh/ # foreignthon-zh (Chinese)
├── docs/ ├── docs/
└── .gitea/workflows/ └── .gitea/workflows/
├── ci.yml # runs tests + lint on every push ├── ci.yml # runs tests + lint on every push
@@ -33,6 +34,7 @@ python -m venv .venv && source .venv/bin/activate
pip install -e "packages/foreignthon[dev]" pip install -e "packages/foreignthon[dev]"
pip install -e packages/langs/es pip install -e packages/langs/es
pip install -e packages/langs/ta pip install -e packages/langs/ta
pip install -e packages/langs/zh
``` ```
## Running tests ## Running tests

View File

@@ -6,6 +6,7 @@
pip install foreignthon pip install foreignthon
pip install foreignthon-es # add Spanish pip install foreignthon-es # add Spanish
pip install foreignthon-ta # add Tamil pip install foreignthon-ta # add Tamil
pip install foreignthon-zh # add Chinese
``` ```
For CLI use across projects, prefer pipx: For CLI use across projects, prefer pipx:
@@ -76,5 +77,6 @@ python -m venv .venv && source .venv/bin/activate
pip install -e "packages/foreignthon[dev]" pip install -e "packages/foreignthon[dev]"
pip install -e packages/langs/es pip install -e packages/langs/es
pip install -e packages/langs/ta pip install -e packages/langs/ta
pip install -e packages/langs/zh
pytest packages/foreignthon/tests/ -v pytest packages/foreignthon/tests/ -v
``` ```

View File

@@ -8,6 +8,7 @@ A language pack is a JSON file that maps foreign tokens to Python equivalents, p
|---|---|---| |---|---|---|
| `foreignthon-es` | Spanish | `pip install foreignthon-es` | | `foreignthon-es` | Spanish | `pip install foreignthon-es` |
| `foreignthon-ta` | Tamil | `pip install foreignthon-ta` | | `foreignthon-ta` | Tamil | `pip install foreignthon-ta` |
| `foreignthon-zh` | Chinese | `pip install foreignthon-zh` |
## JSON schema ## JSON schema

View File

@@ -0,0 +1 @@
# foreignthon-zh

View File

@@ -0,0 +1,22 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "foreignthon-zh"
version = "0.1.0"
description = "Chinese language pack for ForeignThon."
license = { text = "GPL v3" }
requires-python = ">=3.9"
authors = [
{ name = "Cody Trainer" },
]
keywords = ["foreignthon", "chinese", "中文", "mandarin"]
dependencies = ["foreignthon>=0.4.1"]
[project.entry-points."foreignthon.langs"]
zh = "foreignthon_zh"
[tool.hatch.build.targets.wheel]
packages = ["src/foreignthon_zh"]

View File

@@ -0,0 +1,5 @@
from importlib.resources import files
def get_pack_path():
return files(__name__) / "zh.json"

View File

@@ -0,0 +1,149 @@
{
"meta": {
"name": "Chinese",
"native_name": "中文",
"code": "zh",
"version": "0.1.0",
"authors": []
},
"keywords": {
"如果": "if",
"否则": "else",
"否": "elif",
"对于": "for",
"而": "while",
"功能": "def",
"类": "class",
"导入": "import",
"从": "from",
"como": "as",
"返回": "return",
"打断": "break",
"继续": "continue",
"pasar": "pass",
"intentar": "try",
"excepto": "except",
"finalmente": "finally",
"提出": "raise",
"同": "with",
"在": "in",
"是": "is",
"和": "and",
"或": "or",
"不": "not",
"elim": "del",
"global": "global",
"nolocal": "nonlocal",
"afirmar": "assert",
"generar": "yield",
"esperar": "await",
"asinc": "async",
"lambda": "lambda",
"真": "True",
"假": "False",
"空": "None"
},
"builtins": {
"写": "print",
"打印": "print",
"扫描": "input",
"lon": "len",
"dist": "range",
"型": "type",
"数字": "int",
"浮点数": "float",
"字符串": "str",
"列表": "list",
"dicc": "dict",
"conj": "set",
"tupla": "tuple",
"布尔": "bool",
"abrir": "open",
"enumerar": "enumerate",
"map": "map",
"filtrar": "filter",
"ordenado": "sorted",
"invertido": "reversed",
"sum": "sum",
"min": "min",
"max": "max",
"abs": "abs",
"redondear": "round",
"rnd": "round",
"todos": "all",
"alguno": "any",
"esinstancia": "isinstance",
"teneatri": "hasattr",
"obtatri": "getattr",
"estabatri": "setattr",
"repr": "repr",
"formatear": "format",
"vars": "vars",
"sigue": "next",
"id": "id",
"car": "chr",
"十六进制": "hex",
"二进制": "bin",
"八进制": "oct"
},
"exceptions": {
"Excepcion": "Exception",
"ExcepcionBase": "BaseException",
"ErrorDeValor": "ValueError",
"ErrorDeTipo": "TypeError",
"ErrorDeClave": "KeyError",
"ErrorDeIndice": "IndexError",
"ErrorDeAtributo": "AttributeError",
"ErrorDeNombre": "NameError",
"ErrorDeImportacion": "ImportError",
"ErrorDelSistema": "OSError",
"ArchivoNoEncontrado": "FileNotFoundError",
"ErrorDeEjecucion": "RuntimeError",
"DetenerIteracion": "StopIteration",
"SalidaDelSistema": "SystemExit",
"InterrupcionDeTeclado": "KeyboardInterrupt",
"ErrorNoImplementado": "NotImplementedError",
"ErrorDeDivisionCero": "ZeroDivisionError",
"ErrorDeRecursion": "RecursionError",
"ErrorDeSintaxis": "SyntaxError",
"ErrorDeAfirmacion": "AssertionError",
"ErrorDeDesbordamiento": "OverflowError",
"ErrorDeMemoria": "MemoryError",
"ErrorDePermiso": "PermissionError",
"ErrorDeTiempoAgotado": "TimeoutError"
},
"error_messages": {
"SyntaxError": "Error de sintaxis",
"ValueError": "Error de valor",
"TypeError": "Error de tipo",
"KeyError": "Error de clave",
"IndexError": "Error de índice",
"AttributeError": "Error de atributo",
"NameError": "Error de nombre",
"ImportError": "Error de importación",
"FileNotFoundError": "Archivo no encontrado",
"ZeroDivisionError": "Error división por cero",
"RecursionError": "Error de recursión",
"RuntimeError": "Error de ejecución",
"MemoryError": "Error de memoria",
"OverflowError": "Error de desbordamiento",
"AssertionError": "Error de afirmación",
"NotImplementedError": "Error no implementado",
"StopIteration": "Detener iteración",
"KeyboardInterrupt": "Interrupción de teclado",
"PermissionError": "Error de permiso",
"TimeoutError": "Error de tiempo agotado"
},
"stdlib": {
"数学": "math",
"系统": "sys",
"日期时间": "datetime",
"时间": "time",
"aleatorio": "random",
"aleatoria": "random",
"colecciones": "collections",
"ruta": "pathlib",
"er": "re"
},
"postfix_keywords": []
}