@@ -112,6 +112,47 @@ func TestPostprocessLocalizedDocsRewritesPublishedPageLinksForEachLocale(t *test
112112 }
113113}
114114
115+ func TestPostprocessLocalizedDocsDoesNotTreatThreeLetterSourceDirsAsLocales (t * testing.T ) {
116+ t .Parallel ()
117+
118+ docsRoot := t .TempDir ()
119+ writeFile (t , filepath .Join (docsRoot , "docs.json" ), `{"redirects":[]}` )
120+ writeFile (t , filepath .Join (docsRoot , "cli" , "index.md" ), "# CLI\n " )
121+ writeFile (t , filepath .Join (docsRoot , "cli" , "AGENTS.md" ), "# CLI docs guide\n " )
122+ writeFile (t , filepath .Join (docsRoot , "web" , "index.md" ), "# Web\n " )
123+ writeFile (t , filepath .Join (docsRoot , "zh-CN" , "AGENTS.md" ), "# zh-CN\n " )
124+ writeFile (t , filepath .Join (docsRoot , "zh-CN" , ".i18n" , "README.md" ), "# zh-CN i18n\n " )
125+ writeFile (t , filepath .Join (docsRoot , "zh-CN" , "cli" , "index.md" ), "# CLI 本地化\n " )
126+ writeFile (t , filepath .Join (docsRoot , "zh-CN" , "web" , "index.md" ), "# Web 本地化\n " )
127+
128+ pagePath := filepath .Join (docsRoot , "zh-CN" , "gateway" , "index.md" )
129+ writeFile (t , pagePath , stringsJoin (
130+ "---" ,
131+ "title: 网关" ,
132+ "x-i18n:" ,
133+ " source_hash: test" ,
134+ "---" ,
135+ "" ,
136+ "See [CLI](/cli)." ,
137+ "" ,
138+ "See [Web](/web)." ,
139+ ))
140+
141+ if err := postprocessLocalizedDocs (docsRoot , "zh-CN" , []string {pagePath }); err != nil {
142+ t .Fatalf ("postprocessLocalizedDocs failed: %v" , err )
143+ }
144+
145+ got := mustReadFile (t , pagePath )
146+ for _ , want := range []string {
147+ "See [CLI](/zh-CN/cli)." ,
148+ "See [Web](/zh-CN/web)." ,
149+ } {
150+ if ! containsLine (got , want ) {
151+ t .Fatalf ("expected rewritten link %q in output:\n %s" , want , got )
152+ }
153+ }
154+ }
155+
115156func TestPostprocessLocalizedDocsOnlyTouchesScopedFiles (t * testing.T ) {
116157 t .Parallel ()
117158
0 commit comments