Skip to content

Commit 5639b0d

Browse files
authored
Merge pull request #4239 from nfs0619/102
Add XIAO Portuguese documentation
2 parents 6e0f4ea + fff5668 commit 5639b0d

File tree

189 files changed

+97438
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+97438
-11
lines changed

.github/scripts/translate.js

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ const LANGUAGE_CONFIG = {
3131
folder: 'es',
3232
name: 'Español',
3333
pathPrefix: '/es'
34+
},
35+
'pt-BR': {
36+
folder: 'pt-BR',
37+
name: 'Português (Brasil)',
38+
pathPrefix: '/pt-br'
3439
}
3540
};
3641

@@ -62,7 +67,7 @@ const PRESERVE_TERMS = {
6267
};
6368

6469
// 术语表:强制把英文术语译成指定目标语言短语(优先从 .github/scripts/glossary.json 读取;不存在则使用内置空表)
65-
let GLOSSARY = { "zh-CN": {}, "ja": {}, "es": {} };
70+
let GLOSSARY = { "zh-CN": {}, "ja": {}, "es": {}, "pt-BR": {} };
6671
(async () => {
6772
try {
6873
const gPath = path.join(__dirname, 'glossary.json');
@@ -523,7 +528,7 @@ ${glossaryPairs}
523528
' 输出;不得混用其它自然语言。若发生混用,改译为目标语言。\n';
524529
prompt = prompt.replace('<translation_rules>', '<translation_rules>\n' + LANGUAGE_GUARD);
525530

526-
// === 按目标语言替换 <example> 为本地化示例(仅 es / ja 覆盖;默认保留中文示例) ===
531+
// === 按目标语言替换 <example> 为本地化示例(仅 es / ja / pt-BR 覆盖;默认保留中文示例) ===
527532
function getLocalizedExampleBlock(lang) {
528533
if (lang === 'es') {
529534
return (
@@ -609,6 +614,50 @@ Salida incorrecta (prohibido):
609614
[LINE_10] <TabItem value='Install through host'> ❌ label がない場合、value は翻訳する必要がある
610615
[LINE_11] [イントロ](#/Sensor/Guide/ハードウェア概要) ❌ 「#」より前の URL 構造を変更しない
611616
[LINE_12] <a href="https://wiki.seeedstudio.com/Sensor/ABC/#入门指南">Open</a> ❌ 中国語混在
617+
</example>`
618+
);
619+
}
620+
621+
if (lang === 'pt-BR') {
622+
return (
623+
`<example>
624+
Entrada:
625+
[LINE_0] ## Getting Started
626+
[LINE_1][EMPTY_LINE]
627+
[LINE_2] This is a tutorial about:
628+
[LINE_3] - First item
629+
[LINE_4] - [BLE Scanner](#ble-scanner)
630+
[LINE_5] - Nested item
631+
[LINE_6] <strong><span><font color={'FFFFFF'} size={"4"}> Get One Now 🖱️</font></span></strong>
632+
[LINE_7] Click "Settings" in the app (File > Preferences).
633+
[LINE_8] <a className="nav-item"><span className="text">Developer Center</span></a>
634+
[LINE_9] <TabItem value="For E1002" label="For E1002">
635+
[LINE_10] <TabItem value='Install through host'>
636+
[LINE_11] See more: [Intro](/Sensor/Guide/#hardware-overview)
637+
[LINE_12] <a href="https://wiki.seeedstudio.com/Sensor/ABC/#getting-started">Open</a>
638+
639+
Saída correta:
640+
[LINE_0] ## Introdução
641+
[LINE_1][EMPTY_LINE]
642+
[LINE_2] Este é um tutorial sobre:
643+
[LINE_3] - Primeiro item
644+
[LINE_4] - [Scanner BLE](#BLE-Scanner)
645+
[LINE_5] - Item aninhado
646+
[LINE_6] <strong><span><font color={'FFFFFF'} size={"4"}> Adquira agora 🖱️</font></span></strong>
647+
[LINE_7] Clique em "Settings" no aplicativo (File > Preferences).
648+
[LINE_8] <a className="nav-item"><span className="text">Central do Desenvolvedor</span></a>
649+
[LINE_9] <TabItem value="For E1002" label="Para E1002">
650+
[LINE_10] <TabItem value='Instalar pelo host'>
651+
[LINE_11] Veja mais: [Introdução](/Sensor/Guide/#visão-geral-do-hardware)
652+
[LINE_12] <a href="https://wiki.seeedstudio.com/Sensor/ABC/#Primeiros-passos">Open</a>
653+
654+
Saída incorreta (proibido):
655+
[LINE_3] - Primeiro item ❌ Recuo perdido
656+
[LINE_4] - [Scanner BLE](#BLE Scanner) ❌ Espaço no fragmento
657+
[LINE_9] <TabItem value="Para E1002" label="Para E1002"> ❌ Com label, não alterar value
658+
[LINE_10] <TabItem value='Install through host'> ❌ Sem label, value deve ser traduzido
659+
[LINE_11] [Introdução](#/Sensor/Guide/visão-geral-do-hardware) ❌ Não alterar nada antes de "#"
660+
[LINE_12] <a href="https://wiki.seeedstudio.com/Sensor/ABC/#入门指南">Open</a> ❌ Não misturar chinês
612661
</example>`
613662
);
614663
}
@@ -856,7 +905,8 @@ function generateCategoryPrompt(targetLang, pathPrefix) {
856905
const langFilePrefix =
857906
targetLang === 'zh-CN' ? 'cn_' :
858907
targetLang === 'ja' ? 'ja_' :
859-
targetLang === 'es' ? 'es_' : '';
908+
targetLang === 'es' ? 'es_' :
909+
targetLang === 'pt-BR' ? 'pt_' : '';
860910

861911
return `你是一个专业的技术文档翻译专家。请将以下 _category_.yml 文件从英文翻译成${langName}
862912
@@ -944,7 +994,7 @@ function processInternalLinks(content, targetLang) {
944994

945995
// 处理各种链接格式
946996
content = content.replace(
947-
/https:\/\/wiki\.seeedstudio\.com\/((?!zh-CN|ja|es|cn)[^#\s"')]*)/gi,
997+
/https:\/\/wiki\.seeedstudio\.com\/((?!zh-CN|ja|es|pt-BR|cn|pt-br)[^#\s"')]*)/gi,
948998
(match, path) => {
949999
const cleanPath = path.startsWith('/') ? path.slice(1) : path;
9501000
return `https://wiki.seeedstudio.com${pathPrefix}/${cleanPath}`;
@@ -954,7 +1004,7 @@ function processInternalLinks(content, targetLang) {
9541004
content = content.replace(
9551005
/<a\s+([^>]*\s+)?href="(\/[^"]*)"([^>]*)>/gi,
9561006
(match, beforeAttrs, url, afterAttrs) => {
957-
if (url.startsWith('http') || url.match(/^\/(zh-CN|ja|es|cn)\//)) {
1007+
if (url.startsWith('http') || url.match(/^\/(zh-CN|ja|es|pt-BR|cn|pt-br)\//)) {
9581008
return match;
9591009
}
9601010
const newUrl = pathPrefix + url;
@@ -967,7 +1017,7 @@ function processInternalLinks(content, targetLang) {
9671017
content = content.replace(
9681018
/\[([^\]]*)\]\((\/[^)]*)\)/gi,
9691019
(match, text, url) => {
970-
if (url.startsWith('http') || url.match(/^\/(zh-CN|ja|es|cn)\//)) {
1020+
if (url.startsWith('http') || url.match(/^\/(zh-CN|ja|es|pt-BR|cn|pt-br)\//)) {
9711021
return match;
9721022
}
9731023
const newUrl = pathPrefix + url;
@@ -1115,7 +1165,8 @@ function generateTargetPath(originalPath, targetLang) {
11151165

11161166
const langPrefix = targetLang === 'zh-CN' ? 'cn_' :
11171167
targetLang === 'ja' ? 'ja_' :
1118-
targetLang === 'es' ? 'es_' : '';
1168+
targetLang === 'es' ? 'es_' :
1169+
targetLang === 'pt-BR' ? 'pt_' : '';
11191170

11201171
const newFileName = langPrefix + parsedPath.name + parsedPath.ext;
11211172
const newRelativePath = path.join(parsedPath.dir, newFileName);

.github/workflows/pr-translation.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,11 @@ jobs:
221221
comment += `**操作类型:** ${operationSummary}\n\n`;
222222
comment += `### 🚀 开始翻译\n`;
223223
comment += `在此评论回复以下命令之一:\n\n`;
224-
comment += `- \`/translate all\` - 翻译所有变更到所有语言 (中文、日文、西班牙语)\n`;
224+
comment += `- \`/translate all\` - 翻译所有变更到所有语言 (中文、日文、西班牙语、葡萄牙语)\n`;
225225
comment += `- \`/translate zh\` - 仅翻译到中文\n`;
226226
comment += `- \`/translate ja\` - 仅翻译到日文\n`;
227227
comment += `- \`/translate es\` - 仅翻译到西班牙语\n`;
228+
comment += `- \`/translate pt\` - 仅翻译到葡萄牙语 (巴西)\n`;
228229
comment += `- \`/translate zh ja\` - 翻译到中文和日文\n`;
229230
comment += `- \`/translate zh es\` - 翻译到中文和西班牙语\n\n`;
230231
comment += `> 译文将提交到 base 仓库分支 \`auto-translate/pr-<PR号>\` 并打开/复用一个翻译 PR,原 PR 不会被翻译提交污染,也不会阻塞合并。`;
@@ -320,6 +321,7 @@ jobs:
320321
sites/zh-CN/docs
321322
sites/ja/docs
322323
sites/es/docs
324+
sites/pt-BR/docs
323325
sparse-checkout-cone-mode: true
324326
filter: blob:none
325327

@@ -362,12 +364,13 @@ jobs:
362364
comment="${{ github.event.comment.body }}"
363365
echo "🔍 解析翻译命令: $comment"
364366
if [[ "$comment" == *"/translate all"* ]]; then
365-
languages="zh-CN ja es"
367+
languages="zh-CN ja es pt-BR"
366368
else
367369
languages=""
368370
[[ "$comment" == *" zh"* ]] && languages="$languages zh-CN"
369371
[[ "$comment" == *" ja"* ]] && languages="$languages ja"
370372
[[ "$comment" == *" es"* ]] && languages="$languages es"
373+
[[ "$comment" == *" pt"* ]] && languages="$languages pt-BR"
371374
fi
372375
languages=$(echo $languages | xargs)
373376
echo "languages=$languages" >> $GITHUB_OUTPUT
@@ -436,19 +439,20 @@ jobs:
436439
git fetch --depth=1 origin "$BASE_REF"
437440
git checkout "$BASE_REF"
438441
439-
# ✅ 镜像三种语言站点的 docs(含删除)
442+
# ✅ 镜像四种语言站点的 docs(含删除)
440443
rsync -a --delete --safe-links --copy-dirlinks \
441444
--include='sites/' \
442445
--include='sites/zh-CN/' --include='sites/zh-CN/docs/***' \
443446
--include='sites/ja/' --include='sites/ja/docs/***' \
444447
--include='sites/es/' --include='sites/es/docs/***' \
448+
--include='sites/pt-BR/' --include='sites/pt-BR/docs/***' \
445449
--exclude='*' \
446450
"$GITHUB_WORKSPACE/" .
447451
448452
git config user.email "action@github.com"
449453
git config user.name "GitHub Action Bot"
450454
451-
git add sites/zh-CN/docs sites/ja/docs sites/es/docs 2>/dev/null || true
455+
git add sites/zh-CN/docs sites/ja/docs sites/es/docs sites/pt-BR/docs 2>/dev/null || true
452456
453457
if git diff --cached --quiet; then
454458
echo "ℹ️ 镜像后无变化"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"docusaurus-theme-search-typesense": "^0.25.0",
5353
"estree-util-value-to-estree": "^3.5.0",
5454
"moment": "^2.30.1",
55+
"openai": "^6.27.0",
5556
"prism-react-renderer": "^1.3.5",
5657
"react": "^18.3.1",
5758
"react-dom": "^18.3.1",

0 commit comments

Comments
 (0)