Astro Setup
What Tyndale supports in Astro
Section titled “What Tyndale supports in Astro”Tyndale supports two different Astro workflows:
- Astro application translation — translate
.astropages/components with the normaltyndale extract/tyndale translateflow - Astro/Starlight docs translation — translate Markdown/MDX docs with
tyndale translate-docs
Use the app flow for UI strings. Use the docs flow for documentation content.
Astro application translation
Section titled “Astro application translation”-
Install Tyndale
Terminal window npm install tyndale-reactnpm install -D tyndale -
Add Astro’s React integration if needed
tyndale-reactexports React components such as<T>,<Var>, and<Num>. If your Astro project does not already render React components, add Astro’s React integration:Terminal window npx astro add reactSee Astro’s official
@astrojs/reactguide: https://docs.astro.build/en/guides/integrations-guide/react/ -
Initialize Tyndale
Terminal window npx tyndale initinitadds.astrotoextensionsby default. -
Confirm
.astrois included in your config{"extensions": [".ts", ".tsx", ".js", ".jsx", ".astro"]} -
Wrap translatable Astro content
---import { T, Var, Num } from 'tyndale-react';const userName = 'Ada';const count = 3;---<T><h1>Hello <Var name="user">{userName}</Var></h1><p>You have <Num name="count" value={count} /> items.</p></T> -
Run translations
Terminal window npx tyndale translate
Tyndale extracts strings from .astro files through the same extraction pipeline it uses for the rest of your app, then writes translated locale files to public/_tyndale/.
Astro / Starlight docs translation
Section titled “Astro / Starlight docs translation”Use translate-docs when you want to translate documentation content instead of app UI strings.
npx tyndale translate-docs setupnpx tyndale translate-docsSupported docs frameworks:
- Starlight
- Docusaurus
- VitePress
- MkDocs
- Nextra
translate-docs setup detects the docs framework and writes the docs block into tyndale.config.json. For the full docs workflow, see Translating Documentation.