diff --git a/.github/workflows/check-code.yml b/.github/workflows/check-code.yml index 1841e2b..2d1b060 100644 --- a/.github/workflows/check-code.yml +++ b/.github/workflows/check-code.yml @@ -5,7 +5,7 @@ on: jobs: check-i18n: - name: Check Translation Files + name: Check i18n translations runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -15,3 +15,37 @@ jobs: python-version: "3.x" - run: python3 tests/check_i18n.py + + check-json: + name: Validate JSON files + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - run: python3 tests/check_json.py + + check-trailing-newline: + name: Check trailing newlines + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - run: python3 tests/check_trailing_newline.py + + biome-lint: + name: Biome lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: biomejs/setup-biome@v2 + + - run: biome lint src/ diff --git a/.gitignore b/.gitignore index c47fa43..56c7984 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ __MACOSX/ .DS_Store desktop.ini Thumbs.db + +tests/.biome/ diff --git a/README.md b/README.md index 72fc742..c5e1233 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,78 @@ -A Pseudo-localization Translater Demo +# Pseudo Localization Demo 一个伪本地化演示 -伪本地化(pseudo-localization,语言环境名称为 qps-ploc, qps-plocm, qps-ploca, en-XA, en-XB),是模拟本地化过程的一种方式。而通过模拟本地化过程,能够有效地调查在本地化中出现的问题(如字符无法正常显示,或因字符串过长而导致语段显示不完整等)。 +伪本地化 (pseudo-localization, 语言环境名称为 qps-ploc, qps-plocm, qps-ploca, en-XA, en-XB), 是模拟本地化过程的一种方式。而通过模拟本地化过程, 能够有效地调查在本地化中出现的问题 (如字符无法正常显示, 或因字符串过长而导致语段显示不完整等)。 -在伪本地化过程中,英文字母会被替换为来自其他语言的重音符号和字符。(例如,字母 a 可以被 αäáàāāǎǎăăåå 中的任何一个替换。),还会添加分隔符等以增加字符串长度。 -举例:“Windows 照片库(Windows Photo Gallery)”→“ [1iaT9][ Ẅĭпðøωś Þнôтŏ Ģάŀļєяÿ !!! !] ” +在伪本地化过程中, 英文字母会被替换为来自其他语言的重音符号和字符 (例如, 字母 a 可以被 αäáàāāǎǎăăåå 中的任何一个替换), 还会添加分隔符等以增加字符串长度。 +举例: "Windows 照片库 (Windows Photo Gallery)"→" [1iaT9][ Ẅĭпðøωś Þнôтŏ Ģάŀļєяÿ !!! !] " -该网页演示了伪本地化的一部分,即用不同的字符替换英文字母和添加分隔符。 +该网页演示了伪本地化的一部分, 即用不同的字符替换英文字母和添加分隔符。 -更多功能将在之后更新,感谢大家的支持! +此工具不会上传你的任何数据。 + +## 使用 + +如果想要在线预览, 请访问: https://suntrise.github.io/pseudo/ + +如果需要在本地使用, 且您安装了 Python 3, 可以直接执行: +~~~bash +python3 -m http.server 8000 +~~~ +在 `localhost:8000` 中预览页面 + +## 开发 + +### 环境准备 + +| 工具 | 用途 | 安装方式 | +|------|------|----------| +| Python 3 | 运行检查脚本, 或启用本地服务器 | [python.org](https://www.python.org/) | + +### 进行本地化 + +翻译文件位于 `data/i18n.json`, 您可以简单的编辑此 JSON 文件进行进行开发。 + +编辑翻译后, 请运行 i18n 检查以确保翻译质量: + +~~~bash +python3 tests/check_i18n.py +~~~ + +检查内容包括: +- 全角字符检测 +- 缺失/多余的翻译键 +- 空值检测 +- 占位符一致性 +- 首尾空白字符 + +### 开发功能 + +开发完成后, 请执行以下检查确保代码质量: + +~~~bash +# i18n 翻译检查 +python3 tests/check_i18n.py + +# JSON 文件检查 (语法 + 重复键) +python3 tests/check_json.py + +# 文件尾换行符检查 +python3 tests/check_trailing_newline.py + +# JavaScript 代码检查 (首次运行会自动下载 Biome) +python3 tests/check_biome.py +~~~ + +> **Windows 用户** 可能需要将 `python3` 替换为 `python` + +### 检查说明 + +| 检查项 | 脚本 | 说明 | +|--------|------|------| +| i18n 翻译 | `tests/check_i18n.py` | 检查翻译完整性、占位符一致性、全角字符等 | +| JSON 验证 | `tests/check_json.py` | 检查 JSON 语法和重复键 | +| 换行符 | `tests/check_trailing_newline.py` | 检查文本文件是否以换行符结尾 | +| JS 代码 | `tests/check_biome.py` | 检查 JavaScript 代码质量 (自动下载 Biome)| + +所有检查会在 Pull Request 时自动运行。 diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..e471b21 --- /dev/null +++ b/biome.json @@ -0,0 +1,30 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.4.2/schema.json", + "files": { + "includes": ["src/**/*.js"] + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "style": { + "useTemplate": "warn", + "useConst": "warn" + }, + "complexity": { + "useLiteralKeys": "warn" + }, + "correctness": { + "noUnusedImports": "warn", + "noUnusedVariables": "warn", + "useParseIntRadix": "warn" + }, + "suspicious": { + "useIterableCallbackReturn": "warn" + } + } + }, + "formatter": { + "enabled": false + } +} diff --git a/index.html b/index.html index ae2bbbc..fc938e0 100644 --- a/index.html +++ b/index.html @@ -218,4 +218,4 @@