Skip to content

Commit 3945193

Browse files
committed
fix: use codex for docs i18n
1 parent b2d1021 commit 3945193

14 files changed

Lines changed: 330 additions & 1055 deletions

scripts/docs-i18n/doc_chunked_raw.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ func validateDocChunkTranslation(source, translated string) error {
187187
if hasUnexpectedTopLevelProtocolWrapper(source, translated) {
188188
return fmt.Errorf("protocol token leaked: top-level wrapper")
189189
}
190+
if err := validateNoTranslationTranscriptArtifacts(source, translated); err != nil {
191+
return err
192+
}
190193
sourceLower := strings.ToLower(source)
191194
translatedLower := strings.ToLower(translated)
192195
for _, token := range docsProtocolTokens {

scripts/docs-i18n/doc_mode_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,21 @@ func TestValidateDocChunkTranslationRejectsProtocolTokenLeakage(t *testing.T) {
460460
}
461461
}
462462

463+
func TestValidateDocChunkTranslationRejectsTranscriptArtifact(t *testing.T) {
464+
t.Parallel()
465+
466+
source := "Regular paragraph.\n\n"
467+
translated := `Regular paragraph. assistant to=functions.read commentary {"path":"/home/runner/work/docs/docs/source/AGENTS.md"} code`
468+
469+
err := validateDocChunkTranslation(source, translated)
470+
if err == nil {
471+
t.Fatal("expected transcript artifact to be rejected")
472+
}
473+
if !strings.Contains(err.Error(), "agent transcript artifact") {
474+
t.Fatalf("expected transcript artifact error, got %v", err)
475+
}
476+
}
477+
463478
func TestValidateDocChunkTranslationRejectsTopLevelBodyWrapperLeakEvenWhenSourceMentionsBodyTag(t *testing.T) {
464479
t.Parallel()
465480

scripts/docs-i18n/go.mod

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
module github.com/openclaw/openclaw/scripts/docs-i18n
22

3-
go 1.24.0
3+
go 1.25.0
44

55
require (
6-
github.com/joshp123/pi-golang v0.0.4
7-
github.com/yuin/goldmark v1.7.8
8-
golang.org/x/net v0.50.0
6+
github.com/yuin/goldmark v1.8.2
7+
golang.org/x/net v0.53.0
98
gopkg.in/yaml.v3 v3.0.1
109
)

scripts/docs-i18n/go.sum

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
github.com/joshp123/pi-golang v0.0.4 h1:82HISyKNN8bIl2lvAd65462LVCQIsjhaUFQxyQgg5Xk=
2-
github.com/joshp123/pi-golang v0.0.4/go.mod h1:9mHEQkeJELYzubXU3b86/T8yedI/iAOKx0Tz0c41qes=
3-
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
4-
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
5-
golang.org/x/net v0.50.0 h1:ucWh9eiCGyDR3vtzso0WMQinm2Dnt8cFMuQa9K33J60=
6-
golang.org/x/net v0.50.0/go.mod h1:UgoSli3F/pBgdJBHCTc+tp3gmrU4XswgGRgtnwWTfyM=
1+
github.com/yuin/goldmark v1.8.2 h1:kEGpgqJXdgbkhcOgBxkC0X0PmoPG1ZyoZ117rDVp4zE=
2+
github.com/yuin/goldmark v1.8.2/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
3+
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
4+
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
75
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
86
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
97
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

scripts/docs-i18n/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func main() {
6767
maxFiles: *maxFiles,
6868
parallel: *parallel,
6969
}, files, func(srcLang, tgtLang string, glossary []GlossaryEntry, thinking string) (docsTranslator, error) {
70-
return NewPiTranslator(srcLang, tgtLang, glossary, thinking)
70+
return NewCodexTranslator(srcLang, tgtLang, glossary, thinking)
7171
}); err != nil {
7272
fatal(err)
7373
}

scripts/docs-i18n/main_test.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ func (invalidFrontmatterTranslator) TranslateRaw(_ context.Context, text, _, _ s
3737

3838
func (invalidFrontmatterTranslator) Close() {}
3939

40+
type transcriptFrontmatterTranslator struct{}
41+
42+
func (transcriptFrontmatterTranslator) Translate(_ context.Context, text, _, _ string) (string, error) {
43+
return text + ` analysis to=functions.read {"path":"/home/runner/work/docs/docs/source/.agents/skills/openclaw-pr-maintainer/SKILL.md"} code`, nil
44+
}
45+
46+
func (transcriptFrontmatterTranslator) TranslateRaw(_ context.Context, text, _, _ string) (string, error) {
47+
return text, nil
48+
}
49+
50+
func (transcriptFrontmatterTranslator) Close() {}
51+
4052
func TestRunDocsI18NRewritesFinalLocalizedPageLinks(t *testing.T) {
4153
t.Parallel()
4254

@@ -106,3 +118,45 @@ func TestTranslateSnippetDoesNotCacheFallbackToSource(t *testing.T) {
106118
t.Fatalf("expected fallback translation not to be cached")
107119
}
108120
}
121+
122+
func TestTranslateSnippetRejectsTranscriptArtifact(t *testing.T) {
123+
t.Parallel()
124+
125+
tm := &TranslationMemory{entries: map[string]TMEntry{}}
126+
source := "Working with reactions across channels"
127+
128+
translated, err := translateSnippet(context.Background(), transcriptFrontmatterTranslator{}, tm, "tools/reactions.md:frontmatter:read_when:0", source, "en", "th")
129+
if err != nil {
130+
t.Fatalf("translateSnippet returned error: %v", err)
131+
}
132+
if translated != source {
133+
t.Fatalf("expected fallback to source text, got %q", translated)
134+
}
135+
136+
cacheKey := cacheKey(cacheNamespace(), "en", "th", "tools/reactions.md:frontmatter:read_when:0", hashText(source))
137+
if _, ok := tm.Get(cacheKey); ok {
138+
t.Fatalf("expected fallback translation not to be cached")
139+
}
140+
}
141+
142+
func TestValidateNoTranslationTranscriptArtifacts(t *testing.T) {
143+
t.Parallel()
144+
145+
tests := []string{
146+
`表情回应 analysis to=functions.read {"path":"/home/runner/work/docs/docs/source/.agents/skills/openclaw-qa-testing/SKILL.md"} code`,
147+
`กำลังทำงานกับ reactions to=functions.read commentary  ̄第四色json 皇平台`,
148+
`คุณต้องการแผนที่เอกสาร analysis to=final code omitted`,
149+
`Potrzebujesz listy funkcji TUI force_parallel: false} code`,
150+
`กำลังตัดสินใจว่าจะกำหนดค่าผู้ให้บริการสื่อรายใด 全民彩票 casino`,
151+
}
152+
for _, translated := range tests {
153+
if err := validateNoTranslationTranscriptArtifacts("Working with reactions across channels", translated); err == nil {
154+
t.Fatalf("expected artifact to be rejected: %q", translated)
155+
}
156+
}
157+
158+
source := "Document `functions.read` examples exactly."
159+
if err := validateNoTranslationTranscriptArtifacts(source, "Document `functions.read` examples exactly."); err != nil {
160+
t.Fatalf("expected source-owned token to be allowed: %v", err)
161+
}
162+
}

scripts/docs-i18n/pi_command.go

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)