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

📝 docs: add English documents with lobe-i18n #124

Merged
merged 3 commits into from
Nov 24, 2023
Merged

Conversation

arvinxx
Copy link
Collaborator

@arvinxx arvinxx commented Nov 23, 2023

使用 lobe-i18n 实现文档的一键英文翻译。效果如下:

Arvins.video.mp4

操作路径:

  1. 安装依赖 @lobehub/i18n-cli:
pnpm i -D @lobehub/i18n-cli
  1. 添加 .i18nrc.js 配置文件:
/**
 * @type {import("@lobehub/i18n-cli").Config}
 */
module.exports = {
  markdown: {
    entry: ['docs/**/**.md', './README.zh-CN.md'],
    entryLocale: 'zh-CN',
    entryExtension: '.zh-CN.md',
    outputLocales: ['en-US'],
  },
  modelName: 'gpt-3.5-turbo-1106',
};
  1. 执行 lobe-i18n --option 配置 OpenAI API Key:
image
  1. 执行 lobe-i18n md 即可翻译匹配到的全量 md 文件:
image
  1. (可选)可以在 scripts 字段中添加执行脚本:
    "i18n-md": "lobe-i18n md",

@arvinxx arvinxx changed the title 📝 docs: add English document with lobe-i18n 📝 docs: add English documents with lobe-i18n Nov 23, 2023
Copy link

github-actions bot commented Nov 23, 2023

🎊 PR Preview 1f3f99e has been successfully built and deployed to https://ant-design-antd-style-preview-pr-124.surge.sh

🕐 Build time: 105.795s

🤖 By surge-preview

@arvinxx arvinxx merged commit 6f83860 into master Nov 24, 2023
4 checks passed
@arvinxx arvinxx deleted the docs/docs-en branch November 24, 2023 01:47
@arvinxx
Copy link
Collaborator Author

arvinxx commented Nov 24, 2023

补充一键添加 .zh-CN suffix 的 macOS shell 脚本:

find ./docs -type f -name "*.md" -exec sh -c 'for file; do mv "$file" "${file%.md}.zh-CN.md"; done' sh {} +

命令解释:

  • find ./docs -type f -name "*.md":查找 ./docs 目录及其子目录下所有以 .md 结尾的文件。
  • -exec sh -c '...' sh {} +:对找到的文件执行 sh -c,其中 {}find 命令传递给 sh -c 的参数,sh 仅是一个用于 $0 的占位符,并不被使用。这里的 + 表示将所有找到的文件作为参数一次性传递给 sh -c
  • 'for file; do mv "$file" "${file%.md}.zh-CN.md"; done':是一个 sh 脚本,它遍历所有参数(即文件路径),然后对每个文件执行 mv 命令,将 .md 后缀重命名为 .zh-CN.md

使用这个命令,你可以在不安装任何额外软件包的情况下,在 macOS 上批量重命名 docs 文件夹下的 .md 文件。在执行任何批量文件操作之前,确保你有备份,以防不测。

Copy link

github-actions bot commented Dec 8, 2023

🎉 This PR is included in version 3.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants