Segment-level, human-first translation for markdown documentation
Keeping markdown documents in-sync is tricky, and diglot exists to help solve these problems.
- diglot splits markdown documents into segments + uniquely hashes them
- translations are stored in git, with one record per locale and hash
- identical text is translated only once
- changes to URLs, components and HTML can skip re-translation
| Package | Description |
|---|---|
@diglot/core |
Segment model, placeholder form and hashing, validation, apply helpers, segment diff, sentence diff, translation records, policy and glossary types. No parser dependencies. |
@diglot/comark |
Extract and apply for comark documents, plus .navigation.yml files. |
@diglot/mdast |
Extract and apply for markdown and MDX, parsed with remark (remark-parse, remark-gfm, remark-frontmatter, remark-mdc or remark-mdx) or Sätteri. |
@diglot/code |
Comment extraction and apply for fenced code blocks. |
@diglot/store |
Git record store, source manifests, locale bundles, sources.yml and diglot.config.ts loading. |
@diglot/mt |
Machine translation with the AI SDK: page-batched translation, minimal updates of existing translations, glossary and style rules, model-free QA. |
@diglot/action |
GitHub Action that extracts sources, machine-translates what changed and commits the records. |
@diglot/cli |
The diglot command: checkout, extract, diff, validate, build, status. |
@diglot/x18n |
Experimental x18n plugin: hashes as keys, records as messages, source documents as usages. |
@diglot/astro |
Astro integration and content loader that add translated Markdown and MDX pages for the locales of your i18n config, built from the records of a translations repository. |
@diglot/starlight |
Starlight plugin and docs loader that set up @diglot/astro for a Starlight site, its locales and its components. |
In a translations repository:
// diglot.config.ts
import { defineConfig } from '@diglot/core'
export default defineConfig({
locales: ['fr', 'ja'],
})# sources.yml
sources:
- name: nuxt-main
repo: nuxt/nuxt
ref: main
path: ../nuxt
dir: docspnpm dlx @diglot/cli extract # write .diglot/manifest/<source>.json
pnpm dlx @diglot/cli status # coverage per locale and source
pnpm dlx @diglot/cli validate # check every record
pnpm dlx @diglot/cli build # write dist/<locale>.jsonRecords live at <locale>/segments/<hh>/<hash>.json.
- Clone this repository
- Install dependencies using
pnpm install - Run tests using
pnpm test - Run the corpus checks against shallow clones of
nuxt/nuxt(branchesmain,4.x,3.xinnuxt-main,nuxt-4.x,nuxt-3.x) andnuxt/fontsunder$DIGLOT_CORPUS(default/tmp/repos) withpnpm corpus
Made with ❤️
Published under MIT License.