Skip to content

feat: 实现多语言支持 (i18n) + SEO 优化 + GitHub Pages#15

Merged
piratf merged 26 commits intomainfrom
feat-i18n
Jan 31, 2026
Merged

feat: 实现多语言支持 (i18n) + SEO 优化 + GitHub Pages#15
piratf merged 26 commits intomainfrom
feat-i18n

Conversation

@piratf
Copy link
Owner

@piratf piratf commented Jan 30, 2026

概述

为 Windows 文件夹备注工具添加完整的多语言支持 (i18n) 并优化 SEO,支持中文和英文两种语言。同时建设 VitePress 双语文档站点并部署到 GitHub Pages。

主要功能

  • 自动语言检测(Windows 使用 GetUserDefaultLocaleName API)
  • 手动语言切换(--lang 参数)
  • 完整的中英文翻译
  • 打包后的翻译文件正确加载
  • SEO 优化:双语 README、关键词优化、GitHub Topics
  • VitePress 双语文档站点(/en/ 和 /zh/)
  • GitHub Actions 自动部署到 GitHub Pages

更改内容

新增文件

  • locale/zh/LC_MESSAGES/messages.po - 中文翻译源文件
  • messages.pot - 翻译模板文件
  • tests/unit/test_i18n.py - i18n 单元测试(31 个测试用例)
  • docs/ - VitePress 双语文档站点
  • .github/workflows/deploy-docs.yml - GitHub Pages 部署工作流
  • README.en.md - 英文版 README
  • package.json / package-lock.json - VitePress 依赖

修改文件

  • remark/i18n.py - 新增 i18n 核心模块
  • remark/cli/commands.py - 添加 --lang 参数和 UTF-8 编码设置
  • README.md - 主版本(中文为主,含英文摘要)
  • pyproject.toml - 添加 comment 关键词
  • remark.spec - 添加 locale 数据文件到打包配置

SEO 优化

  • 双语 H1 标题:remark + comment 双关键词
  • GitHub About 描述:英文,含核心关键词
  • GitHub Topics:12 个英文标签(GitHub 不支持中文)
  • README 结构:README.md(中文为主)+ README.en.md(英文)
  • 文档站点链接:指向 VitePress 双语门户

版本变更

  • 2.0.5 → 2.0.6

使用示例

```bash

自动检测系统语言

windows-folder-remark.exe

手动指定中文

windows-folder-remark.exe --lang zh

手动指定英文

windows-folder-remark.exe --lang en
```

@piratf piratf changed the title feat: 实现多语言支持 (i18n) feat: 实现多语言支持 (i18n) + SEO 优化 + GitHub Pages Jan 30, 2026
piratf added 15 commits January 31, 2026 03:25
- 使用 gettext + babel 实现国际化
- 支持英文和中文
- 自动检测系统语言
- 支持命令行参数 --lang 手动指定语言
- 添加 README.md (英文) 和 README.zh-CN.md (中文)
- 配置 polint 检查翻译文件质量
- 添加 pre-commit hooks 自动提取和检查翻译
- 支持通过 python -m remark.cli 运行模块
- Track messages.pot file for translation completeness checking
- Use pybabel update --check instead of custom script
- Rename README.zh-CN.md to README.zh.md (W3C standard)
- Update language badges in README files
- Add i18n completeness check to pre-commit hooks
- 新增 _get_windows_locale() 函数,使用 ctypes 调用 Windows API
- 优先使用 GetUserDefaultLocaleName 获取用户默认区域设置
- 改进 get_system_language() 处理各种 locale 格式
- 添加 i18n 单元测试(31 个测试用例)
- 修复 --lang 参数帮助文本(zh_CN -> zh)
主要更改:
- remark.spec: 添加 locale_datas 收集 .mo 文件到打包
- remark/i18n.py: 修复 _get_locale_dir() 路径解析,打包后使用 sys._MEIPASS/locale
- remark/cli/commands.py: 在 main() 中强制设置控制台编码为 UTF-8
- Bump version from 2.0.5 to 2.0.6
- Add 'comment' keyword to pyproject.toml for SEO
- Update README with dual-language H1 title
- Add badges (Python version, License)
- Add Star Us section
- Enhance description with remark/comment keywords
- Update GitHub About description via gh CLI
- Add 12 topics: windows, folder, remark, comment, desktop, command-line, utility, python, portable, cli, automation, tool
- Add VitePress configuration with English and Chinese locales
- Create documentation structure: /en/ and /zh/
- Add getting started, usage, and API reference pages
- Add documentation links to README.md
- Update .gitignore to exclude node_modules
- Rename README.zh.md to README.en.md (English version)
- Update README.md to be the primary Chinese version with English summary
- Update language switch badges to point to README.md and README.en.md
- Add GitHub Actions workflow to deploy VitePress site to GitHub Pages
Modify get_system_language() to check LANG environment variable first
before Windows API. This allows tests to reliably control language
by setting LANG environment variable in conftest.py.

Also update test_windows_platform_priority to clear LANG env var
to properly test Windows API fallback behavior.
Add explicit set_language("zh") call in pytest_configure to ensure
all tests use Chinese translations. This fixes test failures where
tests expected Chinese output but got English.
Move sys import to the beginning of pytest_configure function
to avoid UnboundLocalError.
Add an autouse fixture that calls set_language("zh") before each test.
This ensures the translator is initialized to Chinese even if modules
were imported before pytest_configure ran.
Move set_language("zh") call to module level in conftest.py,
executing before any test modules are imported. This ensures
the translator is initialized to Chinese globally.

Also change autouse fixture scope to session for efficiency.
Add debug output in conftest.py to help diagnose why
translation files are not being loaded correctly in CI.
- Remove .mo files from .gitignore to allow them in repository
- Add locale/zh/LC_MESSAGES/messages.mo to enable translations in CI
- This fixes the issue where tests in CI were outputting English
  instead of Chinese due to missing translation files

The .mo file is compiled from .po source using pybabel compile.
Including compiled files in the repository ensures translations work
in all environments without requiring build tools.
- 移除 "约 12MB" 等具体版本号信息
- 移除 "隐私优先" 等不够具体的描述
- 统一修改为:
  - "无系统驻留,无数据上传,安全放心,用完即走" (中文)
  - "No system residency, no data upload, safe and secure, use it when you need it" (英文)

修改文件:
- README.md
- README.en.md
- docs/zh/index.md
- docs/en/index.md
@piratf piratf merged commit 9f91170 into main Jan 31, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant