Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI 参考如何汉化? #2

Closed
522247020 opened this issue Apr 28, 2024 · 5 comments
Closed

CLI 参考如何汉化? #2

522247020 opened this issue Apr 28, 2024 · 5 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@522247020
Copy link
Contributor

命令行参考界面也是常用的查询页面,这个页面的汉化如何来做?

@522247020 522247020 added the documentation Improvements or additions to documentation label Apr 28, 2024
@522247020
Copy link
Contributor Author

@frostming 大哥有啥办法没!

@frostming
Copy link
Contributor

frostming commented May 23, 2024

无好办法

或许只能解析 help 内容生成.pot 翻译文件,但这样恐怕太复杂了

那目前单独做一个网页手动更新呢?

总之CLI help是通过python脚本自动生成的,你有办法映射成中文怎么都行。python脚本的自由度还是有的

@522247020
Copy link
Contributor Author

无好办法
或许只能解析 help 内容生成.pot 翻译文件,但这样恐怕太复杂了

那目前单独做一个网页手动更新呢?

总之CLI help是通过python脚本自动生成的,你有办法映射成中文怎么都行。python脚本的自由度还是有的

我使用 Python 自带的 gettext 库进行操作,出现了一个问题

- `--copier`: Use Copier to generate project [not installed] (default: `builtin`)
- `--cookiecutter`: Use Cookiecutter to generate project [not installed] (default: `builtin`)

在命令行显示的颜色是 红色的

image

而在网页中出现了命令行的颜色转换符号!

image

我不清楚是不是我使用 win 的问题。

@522247020
Copy link
Contributor Author

在我本地测试,使用 mkdocs serve 预览网页情况,工作目录是 pdm-docs-zh 这个目录,

import gettext
import argparse
import re
from pathlib import Path
from pdm.core import Core


localedir = Path("locale")
t = gettext.translation('cli', localedir=localedir, languages=['zh-CN'])

代码需要导入 locale 这个文件夹,我不确定提交代码后,执行构建文档的过程中能否找到这个文件夹
@frostming

@522247020 522247020 mentioned this issue Jun 3, 2024
@522247020
Copy link
Contributor Author

cli 汉化完成!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants