You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A robust tool for translating gettext (.po) files using AI models from multiple providers (OpenAI, Azure OpenAI, Anthropic / Claude, and DeepSeek). It supports both bulk and individual translations, handles fuzzy entries, and can infer target languages based on folder structures. Available as a Python package and Docker container with support for Python 3.8-3.12.
7
+
A robust tool for translating gettext (.po) files using AI models from multiple providers (OpenAI, Azure OpenAI, Anthropic/Claude, and DeepSeek). It supports both bulk and individual translations, handles fuzzy entries, and can infer target languages based on folder structures. Available as a Python package and Docker container with support for Python 3.8-3.12.
8
8
9
9
## What is GPT-PO Translator?
10
10
@@ -15,6 +15,7 @@ This tool helps you translate gettext (.po) files using AI models. It's perfect
15
15
-**Multiple AI providers** - OpenAI, Azure OpenAI, Anthropic/Claude, and DeepSeek
16
16
-**Flexible translation modes** - Bulk or entry-by-entry processing
17
17
-**Smart language handling** - Auto-detects target languages from folder structure
18
+
-**AI translation tracking** - Automatically tags AI-generated translations with comments
18
19
-**Production-ready** - Includes retry logic, validation, and detailed logging
19
20
-**Easy deployment** - Available as a Python package or Docker container
20
21
-**Cross-version support** - Works with Python 3.8-3.12
**By default, all AI-generated translations are automatically marked with comments** for easy tracking and compliance:
146
+
147
+
```bash
148
+
# Default behavior - AI translations are tagged with comments
149
+
gpt-po-translator --folder ./locales --lang de
150
+
151
+
# Result in PO file:
152
+
#. AI-generated
153
+
msgid "Hello"
154
+
msgstr "Hallo"
155
+
156
+
# To disable AI tagging (not recommended)
157
+
gpt-po-translator --folder ./locales --lang de --no-ai-comment
158
+
```
159
+
160
+
This helps you:
161
+
- Identify which translations were made by AI vs human translators
162
+
- Track incremental changes when new AI translations are added
163
+
- Comply with requirements to identify AI-generated content
164
+
165
+
**Note:** Django's `makemessages` removes these comments when updating PO files, but translations are preserved. Re-run the translator after `makemessages` to restore AI tagging.
166
+
126
167
## Command Reference
127
168
128
169
| Option | Description |
129
170
|--------|-------------|
130
171
|`--folder`| Path to your .po files |
131
172
|`--lang`| Target language codes (comma-separated, e.g., `de,fr`) |
132
173
|`--detail-lang`| Full language names (e.g., `"German,French"`) |
133
-
|`--fuzzy`| Remove fuzzy entries before translating |
174
+
|`--fuzzy`| Remove fuzzy entries before translating (DEPRECATED - use `--fix-fuzzy`) |
175
+
|`--fix-fuzzy`| Translate and fix fuzzy entries properly (recommended) |
134
176
|`--bulk`| Enable batch translation (recommended for large files) |
135
177
|`--bulksize`| Entries per batch (default: 50) |
136
178
|`--model`| Specific AI model to use |
137
-
|`--provider`| AI provider: `openai`, `anthropic`, or `deepseek`|
179
+
|`--provider`| AI provider: `openai`, `azure_openai`, `anthropic`, or `deepseek`|
138
180
|`--list-models`| Show available models for selected provider |
139
181
|`--api_key`| Your API key |
140
182
|`--folder-language`| Auto-detect languages from folder structure |
183
+
|`--no-ai-comment`| Disable AI-generated comment tagging (enabled by default) |
Copy file name to clipboardExpand all lines: docs/usage.md
+101-8Lines changed: 101 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ This guide provides an in-depth look at what really happens when you run `gpt-po
6
6
7
7
## Overview
8
8
9
-
`gpt-po-translator` is a multi-provider tool for translating gettext (.po) files using AI models. It supports OpenAI, Anthropic, and DeepSeek. The tool offers two primary translation modes:
9
+
`gpt-po-translator` is a multi-provider tool for translating gettext (.po) files using AI models. It supports OpenAI, Azure OpenAI, Anthropic, and DeepSeek. The tool offers two primary translation modes:
10
10
-**Bulk Mode:** Processes a list of texts in batches to reduce the number of API calls.
11
11
-**Individual Mode:** Translates each text entry one-by-one for more fine-grained control.
12
12
@@ -22,9 +22,9 @@ It also manages fuzzy translations (by disabling or removing them) and can infer
22
22
23
23
-**API Key Setup:**
24
24
The tool collects API keys from multiple sources:
25
-
- Specific arguments (`--openai-key`, `--anthropic-key`, `--deepseek-key`)
25
+
- Specific arguments (`--openai-key`, `--azure-openai-key`, `--anthropic-key`, `--deepseek-key`)
26
26
- A fallback argument (`--api_key`) for OpenAI if no dedicated key is provided
It then initializes a `ProviderClients` instance that creates API client objects for the chosen providers.
30
30
@@ -76,7 +76,7 @@ It also manages fuzzy translations (by disabling or removing them) and can infer
76
76
The tool checks whether the translation is excessively verbose compared to the original text. If so, it retries the translation to ensure it remains concise.
77
77
78
78
-**Updating PO Files:**
79
-
After translation, each PO file entry is updated with the new translation using `polib`. The tool logs a summary of how many entries were successfully translated and warns if any remain untranslated.
79
+
After translation, each PO file entry is updated with the new translation using `polib`. By default, AI-generated translations are marked with a comment (`#. AI-generated`) for easy identification. The tool logs a summary of how many entries were successfully translated and warns if any remain untranslated.
80
80
81
81
---
82
82
@@ -114,9 +114,14 @@ Below is a detailed explanation of all command-line arguments:
114
114
*Behind the scenes:* These names are used in the translation prompts to give the AI clearer context, potentially improving translation quality.
115
115
*Note:* The number of detailed names must match the number of language codes.
116
116
117
-
-**`--fuzzy`**
118
-
*Description:* A flag that, when set, instructs the tool to remove fuzzy entries from the PO files before translation.
119
-
*Behind the scenes:* The tool calls a dedicated method to strip fuzzy markers and flags from both the file content and metadata.
117
+
-**`--fuzzy`***(DEPRECATED)*
118
+
*Description:* A flag that, when set, instructs the tool to remove fuzzy entries from the PO files before translation. **This option is DEPRECATED due to its risky behavior of removing fuzzy markers without actually translating the content.**
119
+
*Behind the scenes:* The tool calls a dedicated method to strip fuzzy markers and flags from both the file content and metadata.
120
+
*Warning:* This can lead to data loss and confusion. Use `--fix-fuzzy` instead.
121
+
122
+
-**`--fix-fuzzy`**
123
+
*Description:* Translate and clean fuzzy entries safely (recommended over `--fuzzy`).
124
+
*Behind the scenes:* The tool filters for entries with the 'fuzzy' flag and attempts to translate them, removing the flag upon successful translation. AI-generated translations are marked as usual unless `--no-ai-comment` is used.
120
125
121
126
-**`--bulk`**
122
127
*Description:* Enables bulk translation mode, meaning multiple texts will be translated in a single API call.
@@ -131,7 +136,7 @@ Below is a detailed explanation of all command-line arguments:
131
136
*Behind the scenes:* This key is merged with keys provided through other command-line arguments or environment variables.
132
137
133
138
-**`--provider <provider>`**
134
-
*Description:* Specifies the AI provider to use for translations. Acceptable values are `openai`, `anthropic`, or `deepseek`.
139
+
*Description:* Specifies the AI provider to use for translations. Acceptable values are `openai`, `azure_openai`, `anthropic`, or `deepseek`.
135
140
*Behind the scenes:* If not specified, the tool auto-selects the first provider for which an API key is available.
136
141
137
142
-**`--model <model>`**
@@ -150,6 +155,18 @@ Below is a detailed explanation of all command-line arguments:
150
155
*Description:* Provides the Anthropic API key directly.
151
156
*Behind the scenes:* This key is used to initialize the Anthropic client.
152
157
158
+
-**`--azure-openai-key`**
159
+
*Description:* Provides the Azure OpenAI API key directly.
160
+
*Behind the scenes:* This key is used to initialize the Azure OpenAI client.
161
+
162
+
-**`--azure-openai-endpoint`**
163
+
*Description:* Provides the Azure OpenAI endpoint URL (e.g., `https://your-resource.openai.azure.com/`).
164
+
*Behind the scenes:* Required for Azure OpenAI connections along with the API version.
165
+
166
+
-**`--azure-openai-api-version`**
167
+
*Description:* Specifies the Azure OpenAI API version (e.g., `2024-02-01`).
168
+
*Behind the scenes:* Different API versions support different features and models.
169
+
153
170
-**`--deepseek-key`**
154
171
*Description:* Provides the DeepSeek API key directly.
155
172
*Behind the scenes:* This key is required to make API calls to DeepSeek’s translation service.
@@ -158,13 +175,89 @@ Below is a detailed explanation of all command-line arguments:
158
175
*Description:* Enables inferring the target language from the folder structure.
159
176
*Behind the scenes:* The tool inspects the path components (directory names) of each PO file and matches them against the provided language codes.
160
177
178
+
-**`--no-ai-comment`**
179
+
*Description:* Disables the automatic addition of 'AI-generated' comments to translated entries.
180
+
*Behind the scenes:***By default (without this flag), every translation made by the AI is marked with a `#. AI-generated` comment in the PO file.** This flag prevents that marking, making AI translations indistinguishable from human translations in the file.
181
+
*Note:* AI tagging is enabled by default for tracking, compliance, and quality assurance purposes.
182
+
183
+
---
184
+
185
+
## AI Translation Tracking
186
+
187
+
### Overview
188
+
189
+
**AI translation tracking is enabled by default.** The tool automatically tracks which translations were generated by AI versus human translators. This is particularly useful for:
190
+
- Quality assurance and review processes
191
+
- Compliance with requirements to identify AI-generated content
192
+
- Incremental translation workflows where you need to track changes
193
+
194
+
### How It Works
195
+
196
+
When a translation is generated by the AI, the tool adds a translator comment to the PO entry:
197
+
198
+
```po
199
+
#. AI-generated
200
+
msgid "Hello, world!"
201
+
msgstr "Hola, mundo!"
202
+
```
203
+
204
+
These comments are:
205
+
-**Persistent**: They're saved in the PO file and preserved across edits
206
+
-**Standard-compliant**: Using the official gettext translator comment syntax (`#.`)
207
+
-**Tool-friendly**: Visible in PO editors like Poedit, Lokalize, etc.
208
+
-**Searchable**: Easy to find with grep or other search tools
0 commit comments