|
| 1 | +# Translation |
| 2 | + |
| 3 | +Actionbase documentation is translated using a **Translation Memory (TM)** |
| 4 | +workflow. English is the source language; translations are generated by |
| 5 | +applying exact-match TM lookups to the English MDX files. |
| 6 | + |
| 7 | +Translation Memory (TM) is a key-value store that maps English source |
| 8 | +segments to their translations. Each document has its own TM file, |
| 9 | +managed at the document level. |
| 10 | + |
| 11 | +## How it works |
| 12 | + |
| 13 | +``` |
| 14 | +en/*.mdx ──┐ ┌──────────────┐ ┌─────────────┐ ┌──────────┐ |
| 15 | + ├──▶│ Parse MDX │──▶│ TM Lookup │──▶│ Generate │──▶ {lang}/*.mdx |
| 16 | +tm/*.yaml ─┘ │ (segments) │ │ HIT→target │ │ output │ |
| 17 | + └──────────────┘ │ MISS→source │ └──────────┘ |
| 18 | + └─────────────┘ |
| 19 | +``` |
| 20 | + |
| 21 | +The build command parses each English MDX into **segments** (title, |
| 22 | +description, headings, paragraphs, tables, list items). Each segment is |
| 23 | +looked up by exact string match — a **HIT** replaces the English text |
| 24 | +with the translation, and a **MISS** keeps the English text as-is. |
| 25 | +Non-translatable content (code blocks, imports, JSX, images) passes |
| 26 | +through unchanged. |
| 27 | + |
| 28 | +Translated headings receive an explicit `{#english-slug}` anchor derived |
| 29 | +from the English source heading, ensuring cross-page links remain valid |
| 30 | +regardless of the translated heading text. |
| 31 | + |
| 32 | +## TM format |
| 33 | + |
| 34 | +Each document has a YAML file at `website/i18n/tm/{lang}/{doc-path}.yaml`: |
| 35 | + |
| 36 | +```yaml |
| 37 | +meta: |
| 38 | + contributors: |
| 39 | + - alice # GitHub username of human contributor |
| 40 | +entries: |
| 41 | + - source: "Core Concepts" |
| 42 | + target: "Translated text" |
| 43 | + context: heading |
| 44 | + - source: "Actionbase is a database for serving user interactions." |
| 45 | + target: "Translated text for the paragraph" |
| 46 | + context: paragraph |
| 47 | +``` |
| 48 | +
|
| 49 | +| Field | Description | |
| 50 | +| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | |
| 51 | +| `meta.contributors` | GitHub usernames of human contributors | |
| 52 | +| `entries[].source` | English text (exact match key) | |
| 53 | +| `entries[].target` | Translated text. Empty string (`""`) = untranslated | |
| 54 | +| `entries[].context` | Segment type: `frontmatter:title`, `frontmatter:description`, `heading`, `paragraph`, `table`, `list_item`, `summary`, `blockquote` | |
| 55 | + |
| 56 | +## File structure |
| 57 | + |
| 58 | +``` |
| 59 | +website/i18n/ |
| 60 | + tm/{lang}/{doc-path}.yaml # Translation Memory per document |
| 61 | + scripts/translation-memory.ts # TM tool |
| 62 | +website/src/content/docs/ |
| 63 | + *.mdx # English source (authoritative) |
| 64 | + {lang}/*.mdx # Generated from TM — do not edit |
| 65 | +TRANSLATION.md # This file |
| 66 | +``` |
| 67 | +
|
| 68 | +## CLI reference |
| 69 | +
|
| 70 | +All commands run from the `website/` directory. The `--lang` flag defaults |
| 71 | +to `ko` and can be changed to target other languages. |
| 72 | +
|
| 73 | +```bash |
| 74 | +npm run translate -- init # Create empty TM files for new EN docs |
| 75 | +npm run translate -- update # Sync TM with updated EN source |
| 76 | +npm run translate -- build # Rebuild translated docs from TM |
| 77 | +npm run translate -- validate # Validate TM without writing files |
| 78 | +npm run translate -- status # Translation coverage (table) |
| 79 | +npm run translate -- status --format=summary # Coverage (markdown) |
| 80 | +npm run translate -- --lang ko status # Target a specific language (default: ko) |
| 81 | +``` |
| 82 | + |
| 83 | +| Command | Purpose | |
| 84 | +| ---------- | ------------------------------------------------------------------------------------- | |
| 85 | +| `init` | Create empty TM entries for documents that have no TM file yet | |
| 86 | +| `update` | Add new segments (empty target), remove stale entries, preserve existing translations | |
| 87 | +| `build` | Generate `{lang}/*.mdx` from TM lookups | |
| 88 | +| `validate` | Dry-run build to catch YAML or segment errors | |
| 89 | +| `status` | Show per-document HIT/MISS counts and coverage percentage | |
| 90 | + |
| 91 | +| Flag | Description | |
| 92 | +| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | |
| 93 | +| `--lang` | Target language (default: `ko`) | |
| 94 | +| `--model` | LLM model identifier. When set and a document has no human contributors, `translated-by-{model}: true` is added to the output frontmatter. Useful for external workflows that auto-generate TM via LLM | |
| 95 | + |
| 96 | +CI runs `validate` on pull requests and `build` on merge to main. |
| 97 | + |
| 98 | +## Known limitations |
| 99 | + |
| 100 | +- **Exact match only** — any change to an English segment requires |
| 101 | + updating the corresponding TM entry. Use `update` to detect new/stale |
| 102 | + segments automatically. |
| 103 | +- **Multi-line JSX components** (e.g., `<LinkCard>`) are passed through |
| 104 | + and may reformat slightly. |
0 commit comments