Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Every 401 carries `WWW-Authenticate`, and each project reads its configuration f
- A prompt that gets 10 invalid answers, or whose input ends, exits with status 1. `startdemo -y` asks only for the project name, and `runserver` rejects an invalid `app_module` in `[tool.fastapi-fastkit]`.
- `init --template` and `startdemo` check the template name before they ask anything, suggest close matches and point to `fastkit list-templates`; the internal template path is shown only with `--debug`.
- After `init` or `startdemo` creates a project, fastkit prints a "Next steps" panel with the commands that apply to that run (project folder, environment, reviewing `.env`, database, server, tests, `addroute`, the next level), and puts the same list in the project's `README.md`. The old "To start your project" line is gone.
- The services step of the next steps reads correctly for one service or several.
- `runserver` in a project without `.venv` prints the commands that create it for the project's package manager (for PDM, ones that keep the `.venv` inside the project) before offering to continue. If you continue, it runs the uvicorn of the Python that runs fastkit and exits with a clear message if that Python has none.
- `addroute` on a real single-file project such as `fastapi-hello` explains how to extend it by hand instead of adding packages. Projects that keep `main.py` at the root with their code in packages are handled as before.
- `doctor` passed checks say only what was verified, with no severity, and checks that do not apply to a project (secrets, settings, `.gitattributes`) are skipped. JSON output is unchanged.
Expand Down Expand Up @@ -114,6 +115,7 @@ Every 401 carries `WWW-Authenticate`, and each project reads its configuration f
### Documentation

- The documentation is reorganised into Start, Learn, How-to, Reference and Contributing; the Learn track follows one project from `hello` to `production`, and old page addresses redirect to their new pages.
- The documentation is available in seven languages (English, Korean, Japanese, Chinese, Spanish, French and German), with the same pages, menus and generated tables in each.
- CLI reference tables and help texts are generated from the catalog and the CLI, and the configuration-file and environment-variable sections that described settings fastkit never read are removed.
- The documentation translation script leaves code and generated blocks untouched, skips hand-translated pages and fails when a page could not be translated; its workflow offers only the provider the script supports.

Expand Down
197 changes: 6 additions & 191 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,203 +416,18 @@ For more detailed information about security requirements and project guidelines

## Contributing Translations

FastAPI-fastkit documentation supports multiple languages. Contributing translations helps users worldwide.
The documentation is published in seven languages: English (`en`), Korean (`ko`), Japanese (`ja`), Chinese (`zh`), Spanish (`es`), French (`fr`) and German (`de`). English in `docs/en/` is the source, and every page exists at the same path under `docs/<lang>/` in each language.

### Supported Languages
The [Translation Guide](docs/en/contributing/translation-guide.md) describes the whole process: what stays in English, the generated tables, the catalog overlays, the web generator page, the menu labels in `mkdocs.yml`, machine translation with `scripts/translate.py` (`make translate`), and the checks a translation must pass. Follow it rather than this file.

- 🇬🇧 English (en) - Default
- 🇰🇷 Korean (ko)
- 🇯🇵 Japanese (ja)
- 🇨🇳 Chinese (zh)
- 🇪🇸 Spanish (es)
- 🇫🇷 French (fr)
- 🇩🇪 German (de)

### Translation Setup

#### 1. Install Dependencies

```bash
pdm install -G docs -G translation
# Or: pip install mkdocs mkdocs-material mkdocs-static-i18n openai
```

#### 2. Set Up API Key

Get an OpenAI API key (or a key for another OpenAI-compatible API, used with `--api-base-url`) and set it as an environment variable:

```bash
export TRANSLATION_API_KEY="your-api-key-here"
```

#### 3. First-Time Setup (Maintainers Only)

If this is the first time setting up the i18n structure:

```bash
./scripts/setup-i18n-structure.sh
```

This migrates existing English docs to `docs/en/` and creates language directories.

### Translating Documentation

#### Using Make Commands (Recommended)

```bash
# Translate all docs to all configured languages
make translate

# Translate to specific language
make translate LANG=ko

# Specify the model
make translate LANG=ko MODEL=gpt-4
```

#### Using Script Directly
Before opening a translation PR (with the `[DOCS]` tag), run the checks from the guide:

```bash
# Translate all docs to Korean
python scripts/translate.py --target-lang ko --api-provider openai

# Translate specific files (paths relative to docs/en/)
python scripts/translate.py --target-lang ko --files index.md start/installation.md --api-provider openai

# Translate without creating PR (for local testing)
python scripts/translate.py --target-lang ko --no-pr --api-provider openai
python scripts/docs_blocks.py --check
python -m pytest tests/test_docs tests/test_catalog -q
mkdocs build --strict -d site
```

#### Using GitHub Actions

1. Go to repository → Actions → "Translate Documentation"
2. Click "Run workflow"
3. Select target language and options
4. Wait for automated PR to be created
5. Review and merge the translation

### Translation Workflow

1. **Write English documentation** in `docs/en/`
2. **Test locally**: `mkdocs serve`
3. **Commit English version** to main branch
4. **Run translation script** or trigger GitHub Actions
5. **Review PR**: Check formatting, technical terms, links
6. **Merge** and deploy

### Translation Quality Guidelines

When reviewing translations:

- ✅ Markdown formatting is preserved
- ✅ Code blocks are unchanged
- ✅ Technical terms are appropriate
- ✅ Links work correctly
- ✅ Grammar and spelling are correct

### Manual Translation

You can also translate manually:

1. Copy file from `docs/en/` to `docs/{lang}/`
2. Translate the content
3. Create PR with `[DOCS]` tag

### Adding New Languages

To add support for a new language:

1. **Update `mkdocs.yml`**:
```yaml
- locale: pt
name: Português
build: true
```

2. **Run translation**:
```bash
python scripts/translate.py --target-lang pt
```

### Translation System Architecture

**Core Components:**

- **`scripts/translate.py`**: AI-powered translation script
- Calls the OpenAI API, or another OpenAI-compatible API with `--api-base-url`
- Sends only the prose: code blocks and generated blocks stay unchanged
- Creates GitHub PRs automatically

- **`scripts/setup-i18n-structure.sh`**: Migration tool
- Moves docs to language-specific directories
- Creates symbolic links for shared assets

- **`.github/workflows/translate-docs.yml`**: GitHub Actions workflow
- Automated translation on trigger
- Manual workflow dispatch

**Directory Structure:**

```
docs/
├── en/ # English (source)
├── ko/ # Korean
├── ja/ # Japanese
├── zh/ # Chinese
├── es/ # Spanish
├── fr/ # French
├── de/ # German
├── css/ # Shared assets
├── js/
└── img/
```

### Troubleshooting

**Import Error:**
```bash
pip install openai
```

**API Key Error:**
```bash
export TRANSLATION_API_KEY="your-key"
```

**Build Fails:**
```bash
# Ensure docs are in language directories
ls -la docs/en/index.md
```

For detailed translation guidelines, see [Translation Guide](docs/en/contributing/translation-guide.md).

### Updating Navigation Translations

When you add new documentation pages, update navigation translations:

**Option 1: Automatic Update (Recommended)**

```bash
# Update all language nav translations automatically
python scripts/update_nav_translations.py

# With AI translation for missing items
python scripts/update_nav_translations.py --api-key "your-key"
```

**Option 2: Manual Update**

Edit `mkdocs.yml` and add translations for each language under `nav_translations`:

```yaml
- locale: ko
nav_translations:
New Page Title: 새로운 페이지 제목
```

**Note:** Korean translations should be kept complete. Other languages use basic translations (Home, User Guide, Tutorial, etc.). Native speakers can contribute more detailed translations via PR.

## Additional note

If you look at source codes, you will see a commentary at the top of the module that describes about the module.
Expand Down
14 changes: 0 additions & 14 deletions docs/css/custom.css
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
.termynal-comment {
color: #4a968f;
font-style: italic;
display: block;
}

.termy [data-termynal] {
white-space: pre-wrap;
}

.termy .linenos {
display: none;
}

a.external-link::after {
/* \00A0 is a non-breaking space
to make the mark be on the same line as the link
Expand Down
101 changes: 0 additions & 101 deletions docs/css/termynal.css

This file was deleted.

2 changes: 1 addition & 1 deletion docs/de/learn/extend.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ UserRepositoryDep = Annotated[UserRepository, Depends(get_user_repository)]

`uv run pytest -q` meldet jetzt `91 passed`: die 74 Tests, die das Projekt mitgebracht hat, und 17 neue in `tests/test_users.py`.

Zwischen `hello` und `layered` liegt die Stufe `single-file`: die ganze Anwendung in einer einzigen `src/main.py`, dazu Einstellungen und Tests. Dort legt `fastkit addroute` bei der ersten Verwendung die Pakete `api`, `crud`, `schemas` und `core` rund um `src/main.py` an.
Zwischen `hello` und `layered` liegt die Stufe `single-file`: Die ganze Anwendung steckt in einer einzigen `src/main.py`, und das Projekt enthält außerdem Einstellungen und Tests. Dort legt `fastkit addroute` bei der ersten Verwendung die Pakete `api`, `crud`, `schemas` und `core` rund um `src/main.py` an.

## FastAPI-Dokumentation

Expand Down
2 changes: 1 addition & 1 deletion docs/es/learn/extend.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ $ uv run pytest -q

## Cuando un solo archivo no basta

`fastkit addroute` añade un recurso por ti, pero necesita paquetes donde colocar los nuevos módulos. En el proyecto `hello` se niega a hacerlo y te explica por qué:
`fastkit addroute` añade un recurso por ti, pero necesita paquetes donde colocar los nuevos módulos. En el proyecto `hello` se niega a añadir el recurso y te explica por qué:

```console
$ fastkit addroute users .
Expand Down
2 changes: 1 addition & 1 deletion docs/es/learn/generate.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async def read_root(

FastAPI no escucha los requests por sí mismo. El servidor es uvicorn: acepta las conexiones HTTP y pasa cada request a `app` mediante ASGI, la interfaz estándar entre los servidores web de Python y las aplicaciones. `fastkit runserver` inicia uvicorn con `main:app`, que significa «el objeto `app` de `main.py`».

A partir de los paths, las anotaciones de tipos y los tipos de retorno, FastAPI escribe una descripción OpenAPI de tu API: un documento JSON en `/openapi.json` que enumera cada endpoint, sus parámetros y sus responses. Las páginas de `/docs` y `/redoc` se construyen a partir de ese documento. Muestran lo que FastAPI puede leer del código: los paths, los parámetros, los modelos y los códigos de estado que declaras. Un response que solo lanzas dentro de una función, como el 404 de `read_item`, no aparece a menos que lo declares.
A partir de los paths, las anotaciones de tipos y los tipos de retorno, FastAPI escribe una descripción OpenAPI de tu API: un documento JSON en `/openapi.json` que enumera cada endpoint, sus parámetros y sus responses. Las páginas de `/docs` y `/redoc` se construyen a partir de ese documento. Muestran lo que FastAPI puede leer del código: los paths, los parámetros, los modelos y los códigos de estado que declaras. Un response que solo produces al lanzar una excepción dentro de una función, como el 404 de `read_item`, no aparece a menos que lo declares.

## Documentación de FastAPI

Expand Down
2 changes: 1 addition & 1 deletion docs/es/learn/test.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Prueba la aplicación

En esta página ejecutas las pruebas del proyecto `shop` por capas de [Amplía la aplicación](extend.md), lees cómo están construidas y escribes una propia. Aprendes cómo el `TestClient` de FastAPI llama a tu aplicación sin un servidor, cómo los fixtures de pytest preparan cada prueba, cómo `app.dependency_overrides` sustituye una dependencia por una versión de prueba y cómo comprobar la validación y los responses de error. También ves qué pruebas incluye fastkit y cómo las mide la opción de pruebas Coverage.
En esta página ejecutas las pruebas del proyecto `shop` por capas de [Amplía la aplicación](extend.md), lees cómo están construidas y escribes una propia. Aprendes cómo el `TestClient` de FastAPI llama a tu aplicación sin un servidor, cómo los fixtures de pytest preparan cada prueba, cómo `app.dependency_overrides` sustituye una dependencia por una versión de prueba y cómo comprobar la validación y los responses de error. También ves qué pruebas incluye fastkit y cómo la opción de pruebas Coverage mide cuánto código cubren.

## Ejecuta las pruebas

Expand Down
2 changes: 1 addition & 1 deletion docs/es/learn/understand.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ HTTP/1.1 422 Unprocessable Entity

## async def o def

Todos los endpoints de `main.py` son funciones `async def`. Dentro de `async def` puedes usar `await` con otro código asíncrono, como un driver de base de datos asíncrono o un cliente HTTP asíncrono, y el servidor atiende otros requests mientras uno espera. Estos endpoints solo leen y escriben en un diccionario, así que nunca esperan. Usa un `def` normal cuando un endpoint llama a una biblioteca que bloquea (uno que no se usa con `await`): FastAPI lo ejecuta entonces en un pool de hilos, de modo que no retiene los demás requests.
Todos los endpoints de `main.py` son funciones `async def`. Dentro de `async def` puedes usar `await` con otro código asíncrono, como un driver de base de datos asíncrono o un cliente HTTP asíncrono, y el servidor atiende otros requests mientras uno espera. Estos endpoints solo leen y escriben en un diccionario, así que nunca esperan. Usa un `def` normal cuando un endpoint llama a una biblioteca que bloquea (una que no se usa con `await`): FastAPI lo ejecuta entonces en un pool de hilos, de modo que no retiene los demás requests.

## Documentación de FastAPI

Expand Down
2 changes: 1 addition & 1 deletion docs/fr/contributing/template-creation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ app = FastAPI(
```

- La première ligne est une seule phrase et ne nomme pas fastkit ; la seconde ligne contient l'URL seule, qui doit être l'URL d'une entrée `[[concepts]]` du catalogue. Les deux lignes tiennent en 88 colonnes.
- Un template renvoie vers chaque concept au plus une fois. Les identifiants des commentaires d'un template `level` doivent être exactement ceux de sa liste `concepts` dans le catalogue ; les commentaires d'un template `example` doivent figurer dans sa liste.
- Un template renvoie vers chaque concept au plus une fois. Les identifiants des commentaires d'un template `level` doivent être exactement ceux de sa liste `concepts` dans le catalogue ; les identifiants des commentaires d'un template `example` doivent figurer dans sa liste.
- Le bloc se place juste au-dessus du code : ni à l'intérieur d'un bloc d'imports, ni entre un décorateur et sa fonction.
- Les fichiers sous `modules/` ne portent aucun commentaire de concept.

Expand Down
Loading
Loading