Files
openclaw/scripts/docs-i18n/relocalize.go
Mason 9b0ea7c579 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
2026-04-06 22:37:35 +08:00

41 lines
790 B
Go

package main
import (
"os"
)
func postprocessLocalizedDocs(docsRoot, targetLang string, localizedFiles []string) error {
if targetLang == "" || targetLang == "en" || len(localizedFiles) == 0 {
return nil
}
routes, err := loadRouteIndex(docsRoot, targetLang)
if err != nil {
return err
}
for _, path := range localizedFiles {
content, err := os.ReadFile(path)
if err != nil {
return err
}
frontMatter, body := splitFrontMatter(string(content))
rewrittenBody := routes.localizeBodyLinks(body)
if rewrittenBody == body {
continue
}
output := rewrittenBody
if frontMatter != "" {
output = "---\n" + frontMatter + "\n---\n\n" + rewrittenBody
}
if err := os.WriteFile(path, []byte(output), 0o644); err != nil {
return err
}
}
return nil
}