docs: relocalize stale locale links#61796
Conversation
Greptile SummaryThis PR fixes a longstanding ordering bug in the docs i18n pipeline where index pages translated before their child locale pages existed would retain stale English links instead of locale-prefixed ones. The fix decouples link localization from the per-page translation step and instead runs a single postprocess pass ( Key changes:
Confidence Score: 5/5Safe to merge; the redesign is correct and all prior review concerns have been addressed in this revision. The previous P1 concern about missing newline before the closing front-matter delimiter is resolved: the reconstruction in relocalize.go uses '"--- No files require special attention. Prompt To Fix All With AIThis is a comment left during a code review.
Path: scripts/docs-i18n/relocalize_test.go
Line: 50-58
Comment:
**Redundant `stringsJoin` helper**
This helper is functionally identical to `strings.Join(lines, "\n")` from the standard library. Replacing it keeps the test helpers minimal and avoids dead code.
```suggestion
func stringsJoin(lines ...string) string {
return strings.Join(lines, "\n")
}
```
How can I resolve this? If you propose a fix, please make it concise.Greploops — Automatically fix all review issues by running Reviews (2): Last reviewed commit: "docs: relocalize partial docs runs" | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dfb90dde2c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b71837c365
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@greptile-apps review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 56b80002cd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e31e1dc59b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
dea1f52 to
3c90456
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
3082ae7 to
11e5d14
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
236c5b5 to
5b69b22
Compare
5b69b22 to
faa6890
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: faa6890309
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| output := updatedFront + translatedBody | ||
| return false, os.WriteFile(outputPath, []byte(output), 0o644) | ||
| return false, outputPath, os.WriteFile(outputPath, []byte(output), 0o644) |
There was a problem hiding this comment.
Avoid finalizing doc output before relocalize succeeds
This writes the translated file (including a fresh x-i18n.source_hash) before link relocalization runs in runDocsI18N, so if the later postprocessLocalizedDocs step errors (for example on route-index/file I/O), the doc is left with stale English-root links but will be treated as up-to-date on retry with --overwrite=false via shouldSkipDoc. That makes a failed run sticky: reruns can skip the broken file indefinitely unless the source changes or overwrite is forced.
Useful? React with 👍 / 👎.
* 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
* 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
* 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
* 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
* 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
* 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
Summary
Verification trigger
docs/gateway/index.mdis intentional/gatewaylocale pages back through the publish/translation pipeline so we can verify the stale locale-link fix actually propagates inopenclaw/docsTest plan
go test ./...inscripts/docs-i18nRoot cause
scripts/docs-i18n/order.go), so index pages likegateway/index.mdcan be translated before locale child pages such asgateway/troubleshooting.mdexistlocalizedRoutes(scripts/docs-i18n/localized_links.go)scripts/docs-i18n/doc_mode.go), so once a page is written with stale English links it will usually be skipped on later runs unless the English source changesDesign
Current design before this PR:
flowchart TD A[Collect changed English docs] --> B[Sort files by relative path] B --> C[Translate one page] C --> D[Try to localize links immediately] D --> E{Does localized target page already exist?} E -- yes --> F[Write locale-prefixed link] E -- no --> G[Keep English root-relative link] F --> H[Write localized page] G --> H H --> I[Future runs compare only source_hash] I --> J[Page usually skipped unless English source changes]Redesigned flow in this PR:
flowchart TD A[Collect changed English docs] --> B[Sort files by relative path] B --> C[Translate one page] C --> D[Write localized page without link rewriting] D --> E{Page write succeeded?} E -- yes --> F[Add output path to successful file set] E -- no --> G[Return run error] F --> H[Repeat for remaining pages] G --> I[Stop translation loop] H --> J[Save translation memory] I --> J J --> K[Build route index from full locale tree] K --> L[Postprocess only files in successful file set] L --> M[Rewrite links using final localized route set] M --> N[Exit success or return original run error] classDef highlight fill:#ffe8a3,stroke:#b7791f,stroke-width:2px,color:#111; classDef success fill:#d9f99d,stroke:#4d7c0f,stroke-width:2px,color:#111; class F,L,M highlight; class E success;What changed in the design
localized_links.goas the single place that decides whether a route should gain a locale prefixContext
/zh-CN/gatewayand/ja-JP/gatewaypointing some body links at English routes even when localized target pages exist/zh-CN/providerscould already look correct: those links were localized successfully because their target locale pages already existed when that page was translated