Skip to content

Commit 53742d4

Browse files
authored
Add guidelines for translation script contributors (#535)
1 parent 7b775a1 commit 53742d4

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

.github/workflows/update-docs.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
name: "Update Translated Docs"
22

3+
# To add more languages, you will update the following:
4+
#
5+
# 1. Update this file
6+
# - Add '!docs/src/content/docs/{lang}/**' to `on.push.paths`
7+
#
8+
# 2. Update docs/astro.config.mjs
9+
# - Add the new language to `plugins.starlightLlmsTxt.exclude` array
10+
# - Update `translations` for `sidebar`'s items
11+
# - Add the new language to `integrations.starlight.locales` array
12+
#
13+
# 3. Update docs/src/scripts/translate.ts
14+
# - Various updates for the new language
15+
#
16+
317
on:
418
push:
519
branches:

docs/src/scripts/translate.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
// How to run this script:
1+
// ----------------------------------------------------------------------------------
2+
// ### Translate document pages to non-English languages ####
3+
// If you want to add a new language, read .github/workflows/update-docs.yml first.
4+
//
5+
// For this file:
6+
// - Add the new language to `languages` object (required)
7+
// - Add the new language to `engToNonEngMapping` object (optional)
8+
// - Add the new language to `engToNonEngInstructions` object (optional)
9+
// - Add new items to LANGUAGE‑SPECIFIC section in the prompts (optional)
10+
//
11+
// ### How to run this script: ###
212
// pnpm i && pnpm --filter docs run translate
13+
// ----------------------------------------------------------------------------------
314

415
import fs from 'fs/promises';
516
import path from 'path';
@@ -722,10 +733,11 @@ async function translateFile(
722733

723734
function shouldSkipFile(filePath: string): boolean {
724735
const rel = path.relative(sourceDir, filePath);
736+
const isLocalizedDoc = Object.keys(languages).some((code) =>
737+
rel.startsWith(`${code}/`),
738+
);
725739
if (
726-
rel.startsWith('ja/') ||
727-
rel.startsWith('ko/') ||
728-
rel.startsWith('zh/') ||
740+
isLocalizedDoc ||
729741
(!filePath.endsWith('.md') && !filePath.endsWith('.mdx'))
730742
) {
731743
return true;

0 commit comments

Comments
 (0)