@@ -37,6 +37,18 @@ func (invalidFrontmatterTranslator) TranslateRaw(_ context.Context, text, _, _ s
3737
3838func (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+
4052func 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+ }
0 commit comments