# General Translation Changelog: gt-cli 2.8.0: Python プロジェクトのサポート
URL: https://generaltranslation.com/ja/blog/gt-cli_v2_8_0.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 
Authors: Ernest McCarter
Published: 2026-03-10

## 概要

`gt` CLI が Python プロジェクトに対応しました。Flask または FastAPI のプロジェクトで [`gt upload`](/docs/cli/reference/commands/upload) を実行すると、Python のソースファイル内にある [`t()`](/docs/python/reference/functions/t) 呼び出しが抽出され、GT プラットフォームに登録されます。

## 変更点

新しい `@generaltranslation/python-extractor` パッケージは、Python のソースファイルを解析して翻訳呼び出しを抽出します。CLI は、`pyproject.toml`、`requirements.txt`、または `setup.py` に `gt-flask` か `gt-fastapi` があるかを確認して、Python プロジェクトを自動検出します。

この抽出ツールは、次を処理します:

* キーワード引数による変数補間を含む `t("string literal")` 呼び出し
* 動的な f-string 式を変数としてマークするための [`declare_var()`](/docs/python/reference/functions/declare-var)
* 抽出時に評価される静的な式を埋め込むための [`declare_static()`](/docs/python/reference/functions/declare-static)
* Python 固有のメタデータ kwargs (`_context`、`_id`、`_max_chars`)  -- JavaScript ライブラリで使われる options オブジェクトではなく、先頭にアンダースコアが付いたキーワード引数

## 例

```python
from gt_flask import t

@app.get("/error")
def error():
    return {"error": t("Something went wrong. Please try again.", _context="error page")}
```

[`gt upload`](/docs/cli/reference/commands/upload) は文字列を抽出し、プラットフォームに登録します。[`gt translate`](/docs/cli/reference/commands/translate) は設定したロケールの翻訳を生成します。JavaScript ライブラリと同じコマンドとワークフローです。

## リンク

* [gt-flask と gt-fastapi の開発ログ](/devlog/gt-flask_v0_1_0)
* [CLI ドキュメント](/docs/cli/reference/config)
* [ソースコード (CLI) ](https://github.com/generaltranslation/gt)
* [ソースコード (Python) ](https://github.com/generaltranslation/gt-python)

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
