Skip to content

Commit

Permalink
Update translation instructions with /en/ folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Metalhearf authored Mar 5, 2025
1 parent 62333fa commit 8284fca
Showing 1 changed file with 19 additions and 30 deletions.
49 changes: 19 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ As time of writing, our repository looks like this:

```txt
src/content/docs/
├── index.mdx # Root index file, acts as homepage
├── configuring # Content - English
├── extensions # Content - English
├── features # Content - English
├── getting-started # Content - English
├── resources # Content - English
├── theming # Content - English
├── de # Translation - German
├── es # Translation - Spanish
├── nl # Translation - Dutch
└── zh # Translation - Chinese
├── en/
│ ├── page1.mdx
│ ├── page2.mdx
├── es/
│ ├── page1.mdx
│ ├── page2.mdx
├── de/
│ ├── page1.mdx
│ ├── page2.mdx
├── nl/
│ ├── page1.mdx
│ ├── page2.mdx
# ... You see the picture
```

Language folders (e.g., `de`, `es`, `nl`, `zh`) contain translations of our documentation. Other directories in that folder contain shared resources and general documentation files (serving as the `en` translation and as a fallback ("root") locale.)

(Yes, we would also prefer having `/en/` in its own folder but we can't right now while hiding `domain.tld/en/` from the url - check [withastro/starlight#1008](https://github.com/withastro/starlight/discussions/1008).
Language folders (e.g., `de`, `es`, `nl`, `zh`) contain translations of our documentation.

### 2. Create a new language folder

Expand All @@ -77,30 +77,22 @@ To add a new language, follow these steps:
mkdir -p src/content/docs/fr
```

2. Copy the structure from the `src/content/docs/` directory (except existing language folders).
2. Copy the content from the `src/content/docs/en` directory (certainly the most up-to-date translation) and start translating.
You can do it manually or by some magic one-liner, do as you please, but maintain the same file hierarchy to ensure consistency.

Here's one way to do it (requires `rsync`):

```bash
rsync -a --exclude='??' src/content/docs/ src/content/docs/fr/
```

This copies everything except folders with exactly two-character names (which correspond to language codes), ensuring that only the structure and non-language-specific content are duplicated.

3. Updating Configuration

Edit `astro.config.mjs` to register the new language:
When adding a new language for the first time, edit `astro.config.mjs` to register the new language:

```ts
(...)
export default defineConfig({
integrations: [
starlight({
title: 'The HyDE project',
defaultLocale: 'root',
defaultLocale: 'en',
locales: {
root: { label: 'English', lang: 'en' },
en: { label: 'English', lang: 'en' },
es: { label: 'Español', lang: 'es' },
de: { label: 'Deutsch', lang: 'de' },
nl: { label: 'Nederlands', lang: 'nl' },
Expand All @@ -110,14 +102,11 @@ export default defineConfig({
(...)
```
4. Translating the Content
4. More
- Open `src/content/docs/fr` and start translating the files.
- Maintain the same filenames and structure as the original content.
- **You do not need to translate everything immediately**—just push the structure and translate progressively. If a translation is missing, Starlight will fall back to the default language and display a notice that the page is not yet translated.
Tip: When adding a new language from scratch, mind the `index.mdx` file, which will need some fixing: ensure links are relative to the root folder, not the language folder (specifically the buttons/hero image).
5. Submit your changes
You know the drill, commit on your branch and make a nice PR. ;) Feel free to add more translations over time and refine the content as needed.

0 comments on commit 8284fca

Please sign in to comment.