Skip to content

Commit 9b0ea7c

Browse files
authored
docs: relocalize stale locale links (#61796)
* docs: relocalize stale locale links * docs: unify locale link postprocessing * docs: preserve relocalized frontmatter * docs: relocalize partial docs runs * docs: scope locale link postprocessing * docs: continue scoped relocalization * docs: drain parallel i18n results * docs: add i18n pipeline link regression tests * docs: clarify i18n pipeline regression test intent * docs: update provider references in i18n tests to use example-provider * fix: note docs i18n link relocalization * docs: rephrase gateway local ws sentence
1 parent 7bb61a0 commit 9b0ea7c

10 files changed

Lines changed: 497 additions & 94 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Docs: https://docs.openclaw.ai
3333
- Gateway/TUI: defer terminal chat finalization for per-attempt lifecycle errors so fallback retries keep streaming before the run is marked failed. (#60043) Thanks @jwchmodx.
3434
- TUI/command messages: strip inbound envelope metadata before rendering command/system messages so async completion notices stop leaking raw wrappers into the operator terminal. (#59985) Thanks @MoerAI.
3535
- TUI/terminal: restore Kitty keyboard protocol and `modifyOtherKeys` state on TUI exit and fatal CLI crashes so parent shells stop inheriting broken keyboard input after `openclaw tui` exits. (#49130) Thanks @biefan.
36+
- Docs/i18n: relocalize final localized-page links after translation so generated locale pages stop keeping stale English-root links when targets appear later in the same run. (#61796) thanks @hxy91819.
3637

3738
## 2026.4.5
3839

docs/gateway/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Fallback: SSH tunnel.
173173
ssh -N -L 18789:127.0.0.1:18789 user@host
174174
```
175175

176-
Then connect clients to `ws://127.0.0.1:18789` locally.
176+
Then connect clients locally to `ws://127.0.0.1:18789`.
177177

178178
<Warning>
179179
SSH tunnels do not bypass gateway auth. For shared-secret auth, clients still

scripts/docs-i18n/doc_mode.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,67 +17,65 @@ const (
1717
bodyTagEnd = "</body>"
1818
)
1919

20-
func processFileDoc(ctx context.Context, translator *PiTranslator, docsRoot, filePath, srcLang, tgtLang string, overwrite bool, routes *routeIndex) (bool, error) {
20+
func processFileDoc(ctx context.Context, translator docsTranslator, docsRoot, filePath, srcLang, tgtLang string, overwrite bool) (bool, string, error) {
2121
absPath, relPath, err := resolveDocsPath(docsRoot, filePath)
2222
if err != nil {
23-
return false, err
23+
return false, "", err
2424
}
2525

2626
content, err := os.ReadFile(absPath)
2727
if err != nil {
28-
return false, err
28+
return false, "", err
2929
}
3030
currentHash := hashBytes(content)
3131

3232
outputPath := filepath.Join(docsRoot, tgtLang, relPath)
3333
if !overwrite {
3434
skip, err := shouldSkipDoc(outputPath, currentHash)
3535
if err != nil {
36-
return false, err
36+
return false, "", err
3737
}
3838
if skip {
39-
return true, nil
39+
return true, "", nil
4040
}
4141
}
4242

4343
sourceFront, sourceBody := splitFrontMatter(string(content))
4444
frontData := map[string]any{}
4545
if strings.TrimSpace(sourceFront) != "" {
4646
if err := yaml.Unmarshal([]byte(sourceFront), &frontData); err != nil {
47-
return false, fmt.Errorf("frontmatter parse failed for %s: %w", relPath, err)
47+
return false, "", fmt.Errorf("frontmatter parse failed for %s: %w", relPath, err)
4848
}
4949
}
5050
frontTemplate, markers := buildFrontmatterTemplate(frontData)
5151
taggedInput := formatTaggedDocument(frontTemplate, sourceBody)
5252

5353
translatedDoc, err := translator.TranslateRaw(ctx, taggedInput, srcLang, tgtLang)
5454
if err != nil {
55-
return false, fmt.Errorf("translate failed (%s): %w", relPath, err)
55+
return false, "", fmt.Errorf("translate failed (%s): %w", relPath, err)
5656
}
5757

5858
translatedFront, translatedBody, err := parseTaggedDocument(translatedDoc)
5959
if err != nil {
60-
return false, fmt.Errorf("tagged output invalid for %s: %w", relPath, err)
60+
return false, "", fmt.Errorf("tagged output invalid for %s: %w", relPath, err)
6161
}
6262
if sourceFront != "" && strings.TrimSpace(translatedFront) == "" {
63-
return false, fmt.Errorf("translation removed frontmatter for %s", relPath)
63+
return false, "", fmt.Errorf("translation removed frontmatter for %s", relPath)
6464
}
6565
if err := applyFrontmatterTranslations(frontData, markers, translatedFront); err != nil {
66-
return false, fmt.Errorf("frontmatter translation failed for %s: %w", relPath, err)
66+
return false, "", fmt.Errorf("frontmatter translation failed for %s: %w", relPath, err)
6767
}
68-
translatedBody = routes.localizeBodyLinks(translatedBody)
69-
7068
updatedFront, err := encodeFrontMatter(frontData, relPath, content)
7169
if err != nil {
72-
return false, err
70+
return false, "", err
7371
}
7472

7573
if err := os.MkdirAll(filepath.Dir(outputPath), 0o755); err != nil {
76-
return false, err
74+
return false, "", err
7775
}
7876

7977
output := updatedFront + translatedBody
80-
return false, os.WriteFile(outputPath, []byte(output), 0o644)
78+
return false, outputPath, os.WriteFile(outputPath, []byte(output), 0o644)
8179
}
8280

8381
func formatTaggedDocument(frontMatter, body string) string {

scripts/docs-i18n/html_translate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type htmlReplacement struct {
1919
Value string
2020
}
2121

22-
func translateHTMLBlocks(ctx context.Context, translator *PiTranslator, body, srcLang, tgtLang string) (string, error) {
22+
func translateHTMLBlocks(ctx context.Context, translator docsTranslator, body, srcLang, tgtLang string) (string, error) {
2323
source := []byte(body)
2424
r := text.NewReader(source)
2525
md := goldmark.New(
@@ -95,7 +95,7 @@ func sortHTMLReplacements(replacements []htmlReplacement) {
9595
})
9696
}
9797

98-
func translateHTMLBlock(ctx context.Context, translator *PiTranslator, htmlText, srcLang, tgtLang string) (string, error) {
98+
func translateHTMLBlock(ctx context.Context, translator docsTranslator, htmlText, srcLang, tgtLang string) (string, error) {
9999
tokenizer := html.NewTokenizer(strings.NewReader(htmlText))
100100
var out strings.Builder
101101
skipDepth := 0

0 commit comments

Comments
 (0)