# General Translation Python SDKs: Quickstart
URL: https://generaltranslation.com/en-US/docs/python/quickstart.mdx
---
title: Quickstart
description: Install the General Translation Python SDK and translate your first Flask or FastAPI app.
related:
links:
- /docs/python/guides/translating-strings
- /docs/python/guides/detecting-locale
- /docs/python/guides/declaring-variables
- /docs/python/guides/storing-translations
---
The General Translation Python SDK translates user-facing strings in Flask and FastAPI apps. You initialize it once with your app, then wrap strings in your routes with the [`t`](/docs/python/reference/functions/t) function, which translates into the current request's locale.
Install the integration for your framework: `gt-flask` for Flask, `gt-fastapi` for FastAPI. Both build on the shared `gt-i18n` runtime, which you can also use directly in a non-framework project.
The Python SDK is **experimental and unstable** — `gt-i18n`, `gt-flask`, and `gt-fastapi` are all at version 0.3.0 and may have breaking changes. It requires Python 3.10 or later.
## What the Python SDK does [#overview]
The SDK gives you:
- **String translation** with `t`, using ICU message syntax.
- **Per-request locale** detection from the `Accept-Language` header, or your own logic.
- **Finite variants** with [`derive`](/docs/python/reference/functions/derive), and non-translatable values with [`declare_var`](/docs/python/reference/functions/declare-var).
- **CDN or local delivery** of translations generated by the [General Translation CLI](/docs/cli/quickstart).
## Quickstart [#quickstart]
Install the integration, add a config file, initialize with your app, and translate a string.
### 1. Install the integration
```bash
pip install gt-flask
```
```bash
pip install gt-fastapi
```
### 2. Configure your locales
Create a `gt.config.json` at your project root with your Project ID and locales. See the [configuration reference](/docs/python/reference/config) for every key.
```json title="gt.config.json"
{
"projectId": "your-project-id",
"defaultLocale": "en",
"locales": ["es", "fr"]
}
```
### 3. Initialize with your app
Call `initialize_gt(app)` once at startup. It reads `gt.config.json`, registers per-request locale detection, and eager-loads translations. There is no API key parameter — CDN loading uses `project_id` and `cache_url`.
```python title="app.py"
from flask import Flask
from gt_flask import initialize_gt, t, get_locale
app = Flask(__name__)
initialize_gt(app)
@app.route("/")
def index():
return {"message": t("Hello, world!"), "locale": get_locale()}
```
```python title="main.py"
from fastapi import FastAPI
from gt_fastapi import initialize_gt, t, get_locale
app = FastAPI()
initialize_gt(app)
@app.get("/")
def index():
return {"message": t("Hello, world!"), "locale": get_locale()}
```
### 4. Translate with variables
Use ICU placeholders and pass values as keyword arguments.
```python
t("Hello, {name}!", name="Alice")
```
### 5. Generate translations
Use the [General Translation CLI](/docs/cli/quickstart) to translate your content before you deploy, so translations are available at runtime.
```bash
gt translate
```
## Use the core library without a framework [#core]
If you are not using Flask or FastAPI, install `gt-i18n` directly. There is no [`initialize_gt`](/docs/python/reference/functions/initialize-gt) in the core library — construct an [`I18nManager`](/docs/python/reference/classes/i18n-manager), register it with [`set_i18n_manager`](/docs/python/reference/functions/set-i18n-manager), and set the request locale yourself.
```bash
pip install gt-i18n
```
```python
from gt_i18n import I18nManager, set_i18n_manager, t
manager = I18nManager(default_locale="en", locales=["es", "fr"])
set_i18n_manager(manager)
manager.set_locale("es")
print(t("Hello, world!"))
```
See [Translating strings](/docs/python/guides/translating-strings) for context and variables, and [Detecting the request locale](/docs/python/guides/detecting-locale) to customize locale detection.
## Next steps
- /docs/python/guides/translating-strings
- /docs/python/guides/detecting-locale
- /docs/python/guides/declaring-variables
- /docs/python/guides/storing-translations